为啥博客园 \(\LaTeX\) 老挂???!

\(\huge{\text{菜}}\)


刚开始写 \(T1\) 的时候,在看到后缀前缀之后,直接想到 \(AC\) 自动机,在画了半个 \(trie\) 树之后:

\(\huge{\text{这题也配用AC自动机???}}\)


然后秒写一个 \(hash\),之后一发过样例,以为稳了。。。

然后。。。

\(freopen\)

还好看到了。。。

不然就暴 \(\color{red}0\) \(\color{green}0\) \(\color{blue}0\) 了

似乎 \(kmp\) 也是可以做的,然而我不明白为什么看到这一题会先想到 \(kmp\) 而不是 \(hash\)。。。

\(code\)



#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
#define debug cout<<"debug"<<endl
//#define int long long
FILE *file_eat; int scan_eat;
namespace xin_io
{
#define freopen file_eat = freopen
#define scanf scan_eat = scanf
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
inline int get()
{
int s = 0,f = 1;
register char ch = gc();
while(!isdigit(ch)) { if(ch == '-') f = -1;ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io;
static const int maxn = 2e5+10;
#define ull unsigned long long
namespace xin
{
class xin_hash
{
public:
ull h[maxn],p[maxn];
int base;
xin_hash(): base(13331){p[0] = 1;}
inline void do_hash(char *s)
{for(register int i=1;s[i];++i)h[i] = h[i-1] * base + (s[i] - 'a' + 1),p[i] = p[i-1] * base;}
inline ull query(int l,int r)
{return h[r] - h[l-1] * p[r - l + 1];}
}ha,hb;
int T,la,lb;
char a[maxn],b[maxn];
inline short main()
{
// #ifndef ONLINE_JUDGE
// openfile();
// #endif
scanf("%d",&T);
while(T--)
{
int ans = 0;
scanf("%d%d",&la,&lb);
scanf("%s",a+1);
// cout<<a+1<<endl;
char plus; cin>>plus; //cout<<"plus = "<<plus<<endl;
for(register int i=1;i<=lb;++i)
b[i] = a[i];
b[++lb] = plus;
ha.do_hash(a); hb.do_hash(b);
// cout<<a[1]<<a[2]<<' '<<b[3]<<b[4]<<endl;
// cout<<ha.query(1,1)<<' '<<hb.query(4,4)<<endl;
int ms = min(la,lb);
// for(register int i=1;b[i];++i) cout<<b[i];
for(register int i=1;i<=ms;++i)
{
register int j = lb - i + 1;
if(ha.query(1,i) == hb.query(j,lb))
ans = i;
}
printf("%d\n",ans);
}
return 0;
}
}
signed main() {return xin::main();}

T2:

冲过 \(T1\) 之后,然后就开心地去冲 \(T2\)了,然后一眼看出 \(tarjan\) 割点板子。。。。

喜提 \(10pts\)

对于每一个割点,并不是都是有效割点,所以,我们只能标记 有效割点,其实只需要在考场代码上面加上两句话:

if(pd[y]) pd[x] = true;

还有判断上:

if((flag > 1 or x != 1) and pd[y]) cut[x] = true;

然后就是在 \(tarjan(i)\) 之前加上 pd[n] = true


就这???

  • 真 就这

    。。。。

所以你考场上为啥没想出来???

杠哥的话说,就是 \(\huge{\text{废*}}\)


别骂了,别骂了。。。。


所以 \(code\):



#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define debug cout<<"debug"<<endl
//#define int long long
FILE *file_eat; int scan_eat;
namespace xin_io
{
#define freopen file_eat = freopen
#define scanf scan_eat = scanf
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
inline int get()
{
int s = 0,f = 1;
register char ch = gc();
while(!isdigit(ch)) { if(ch == '-') f = -1;ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io;
static const int maxn = 1e6+10;
#define ull unsigned long long
#include<cstring>
#define m(c,num) memset(c,num,sizeof c)
namespace xin
{
class xin_edge{public:int next,ver;} edge[maxn<<2];
int n,m;
int num;
int scc_num = 0;
int dfn[maxn],low[maxn];
int head[maxn],zhi;
inline void add(int x,int y)
{
edge[++zhi].ver = y;
edge[zhi].next = head[x]; head[x] = zhi;
}
bool vis[maxn];
bool cut[maxn];
bool pd[maxn];
inline void tarjan(int x)
{
dfn[x] = low[x] = ++num;
// cout<<"x = "<<x<<" dfn[x] = "<<dfn[x]<<endl;
int flag = 0,s = 0;
for(register int i=head[x];i;i=edge[i].next)
{
register int y = edge[i].ver;
if(!dfn[y])
{
tarjan(y);
low[x] = min(low[x],low[y]);
if(low[y] >= dfn[x])
{
flag++;
if((flag > 1 or x != 1) and pd[y]) cut[x] = 1;
}
if(pd[y]) pd[x] = 1;
}
else low[x] = min(low[x],dfn[y]);//,cout<<low[x]<<' '<<dfn[x]<<endl;
}
}
int T;
inline void clean()
{
num = zhi = 0;
m(cut,0); m(low,0); m(dfn,0); m(pd,0);
m(vis,0); m(edge,0); m(head,0);
}
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();// outfile();
#endif
T = get();
for(register int cse=1;cse<=T;++cse)
{
clean();
n = get(); m = get();
for(register int i=1;i<=m;++i)
{
register int x = get(),y = get();
add(x,y); add(y,x);
}
pd[n] = 1;
for(register int i=1;i<=n;++i)
if(!dfn[i])
tarjan(i);
int cnt = 0;
for(register int i=2;i<=n-1;++i)
if(cut[i]) cnt++;//,cout<<"i = "<<i<<" cut[i] = "<<cut[i]<<endl;
if(!cnt) {printf("0\n\n");continue;}
printf("%d\n",cnt);
for(register int i=2;i<=n-1;++i)
if(cut[i]) printf("%d ",i);
printf("\n\n");
clean();
// cout<<(sizeof (edge) + sizeof(cut) + sizeof(dfn) + sizeof(low) + sizeof(vis) + sizeof(head)) / (1 << 20) <<"MB"<<endl;
}
// for(register int i=1;i<=10;++i)
// clean();
return 0;
}
}
signed main(){return xin::main();}

T3:

以为自己切掉 \(T2\) 之后,欢快地去打 \(T3\)。。。

然后。。。

逆序对???

思考一阵子之后,然后陷入了沉思。。。。

到了考试结束的时候也没想出一个所以然来。。。

可能是太想打正解了。。。

还不如莽一个 \(40pts\) 的暴力。

。。。。。


正解就是维护一个前缀和的前缀和,对,就这样。

然后二分起点。。。

之后就没啥了。。。

所以 \(code\):



#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug cout<<"debug"<<endl
FILE *file_eat; int scan_eat;
namespace xin_io
{
#define freopen file_eat = freopen
#define scanf scan_eat = scanf
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
inline int get()
{
int s = 0,f = 1;
register char ch = gc();
while(!isdigit(ch)) { if(ch == '-') f = -1;ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io;
static const int maxn = 2e6+10;
#define m(c,num) memset(c,num,sizeof c)
namespace xin
{
int len,T;
char s[maxn];
int she[maxn],bhe[maxn],brhe[maxn];
int ans;
// inline int random(int x) {return (unsigned)rand() * rand() % x;}
// inline int getst(int l,int r){return random(r-2) + l;}
int srhe[maxn],rhe[maxn];
inline int query(int l,int v,int r)
{return she[v] - she[l-1] - bhe[l-1] * (rhe[v]-rhe[l-1]) + srhe[v+1] - srhe[r+1] - brhe[r+1] * (rhe[r] - rhe[v]);}
inline bool pan(int num)
{
double every = (1.175 / ((1.0 * T))) * 1.0 * num;
// cout<<every<<endl;
register double tim = ((double)clock() / (double)(CLOCKS_PER_SEC));
if(tim >= every) return false;
return true;
}
bool vis[maxn];
int num[maxn];
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
scanf("%lld",&T);
for(register int cse=1;cse<=T;++cse)
{
register int cnt = 1;
scanf("%s",s+1); ans = 0x7f7f7f7f7f7f7f7f;
len = strlen(s+1);
for(register int i=1;i <= len;i++) s[i + len] = s[i];
for(register int i=1;i <= (len * 2);i++)
{
bhe[i] = bhe[i-1]; she[i] = she[i-1]; rhe[i] = rhe[i-1];
if(s[i] == 'R') bhe[i]++;
else rhe[i] ++,she[i] += bhe[i];
// cout<<"bhe[i] = "<<bhe[i]<<" she[i] = "<<she[i]<<endl;
}
for(register int i=(len * 2);i;i--)
{
brhe[i] = brhe[i+1]; srhe[i] = srhe[i+1];
if(s[i] == 'R') brhe[i]++;
else srhe[i] += brhe[i];//,cout<<"srhe[i] = "<<srhe[i]<<endl;
}
for(register int i=1;i<=len;++i)
{
//num[i]++;
// cout<<"len = "<<len<<" i = "<<i<<endl;
// if(vis[i]) continue;vis[i] = true;
while(cnt != len + i and query(i,cnt,i + len - 1) >= query(i,cnt + 1,i + len - 1)) cnt++;
ans = min(ans,query(i,cnt,i + len - 1));
}
cout<<ans<<endl;// m(vis,0);
// for(register int i=1;i<=len;++i)
// cout<<"i = "<<i<<" num[i] = "<<num[i]<<endl;
}
return 0;
}
}
signed main() {return xin::main();}

[考试总结]noip模拟7的更多相关文章

  1. 6.17考试总结(NOIP模拟8)[星际旅行·砍树·超级树·求和]

    6.17考试总结(NOIP模拟8) 背景 考得不咋样,有一个非常遗憾的地方:最后一题少取膜了,\(100pts->40pts\),改了这么多年的错还是头一回看见以下的情景... T1星际旅行 前 ...

  2. 5.23考试总结(NOIP模拟2)

    5.23考试总结(NOIP模拟2) 洛谷题单 看第一题第一眼,不好打呀;看第一题样例又一眼,诶,我直接一手小阶乘走人 然后就急忙去干T2T3了 后来考完一看,只有\(T1\)骗到了\(15pts\)[ ...

  3. 5.22考试总结(NOIP模拟1)

    5.22考试总结(NOIP模拟1) 改题记录 T1 序列 题解 暴力思路很好想,分数也很好想\(QAQ\) (反正我只拿了5pts) 正解的话: 先用欧拉筛把1-n的素数筛出来 void get_Pr ...

  4. [考试总结]noip模拟23

    因为考试过多,所以学校的博客就暂时咕掉了,放到家里来写 不过话说,vscode的markdown编辑器还是真的很好用 先把 \(noip\) 模拟 \(23\) 的总结写了吧.. 俗话说:" ...

  5. 2021.9.17考试总结[NOIP模拟55]

    有的考试表面上自称NOIP模拟,背地里却是绍兴一中NOI模拟 吓得我直接文件打错 T1 Skip 设状态$f_i$为最后一次选$i$在$i$时的最优解.有$f_i=max_{j<i}[f_j+a ...

  6. 「考试」noip模拟9,11,13

    9.1 辣鸡 可以把答案分成 每个矩形内部连线 和 矩形之间的连线 两部分 前半部分即为\(2(w-1)(h-1)\),后半部分可以模拟求(就是讨论四种相邻的情况) 如果\(n^2\)选择暴力模拟是有 ...

  7. 6.11考试总结(NOIP模拟7)

    背景 时间分配与得分成反比,T1 20min 73pts,T2 1h 30pts,T3 2h 15pts(没有更新tot值,本来应该是40pts的,算是本次考试中最遗憾的地方了吧),改起来就是T3比较 ...

  8. 6.10考试总结(NOIP模拟6)

    前言 就这题考的不咋样果然还挺难改的.. T1 辣鸡 前言 我做梦都没想到这题正解是模拟,打模拟赛的时候看错题面以为是\(n\times n\)的矩阵,喜提0pts. 解题思路 氢键的数量计算起来无非 ...

  9. 6.7考试总结(NOIP模拟5)

    前言 昨天说好不考试来着,昨晚就晚睡颓了一会,今天遭报应了,也没好好考,考得挺烂的就不多说了. T1 string 解题思路 比赛上第一想法就是打一发sort,直接暴力,然后完美TLE40pts,这一 ...

  10. [考试反思]NOIP模拟测试19:洗礼

    []260 []230[]210 []200[8]170[9]160 这套题一般,数据很弱,T1T2暴力都能A,而且都是一些思维题,想不到就爆0. 原因不明,很多一直很强的人在这一次滑铁卢了,于是我个 ...

随机推荐

  1. P4779 【模板】单源最短路径(标准版)单源最短路Dijkstra

    题目描述 给定一个$n$个点,$m$条有向边的带非负权图,请你计算从$s$出发,到每个点的距离. 数据保证你能从$s$出发到任意点. 输入格式 第一行为三个正整数$n,m,s$. 第二行起$m$行,每 ...

  2. 【NX二次开发】Block UI 微定位

    属性说明 属性   类型   描述   常规           BlockID    String    控件ID    Enable    Logical    是否可操作    Group    ...

  3. Django基础之模型层(02)

    1 重要概念 # 多表查询 """ 正向查询 反向查询 当前查询对象是否含有外键字段 如果有就是正向 没有无则是反向 口诀: 正向查询按外键字段 多对多需要额外再加一个. ...

  4. kubelet分析-csi driver注册源码分析

    kubelet注册csi driver分析 kubelet注册csi driver的相关功能代码与kubelet的pluginManager有关,所以接下来对pluginManager进行分析.分析将 ...

  5. mysql字符集utf8和utf8mb4区别

    1.起因 公司游戏项目上线第一天,出现单个区服异常宕机的问题,根据日志排查下来,连接数据的时候报错,后面排查是因为有玩家插入Emoji 等表情导致无法存储如数据库,数据库字符集编码为utf8,后续改成 ...

  6. 使用docker搭建最新版本的gitea,并配置HTTPS访问

    使用docker搭建最新版本的gitea,并配置HTTPS访问 博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢! 简介 之前有搭建 ...

  7. 3.QT屏幕分辨率适配

    需求:qt的窗口.组件.字体需要适配屏幕分辨率. 思路:qt是根据显示器的物理长度或者宽度于分辨率的关系来计算dpi 实现: #if(QT_VERSION >= QT_VERSION_CHECK ...

  8. 图的存储与遍历C++实现

    1.图的存储 设点数为n,边数为m 1.1.二维数组 方法:使用一个二维数组 adj 来存边,其中 adj[u][v] 为 1 表示存在 u到 v的边,为 0 表示不存在.如果是带边权的图,可以在 a ...

  9. iOS工程师如何恍然大悟?

    聊聊行情?为什么总有人在乎旁人的看法而忽略自己的初衷? 虽然iOS开发市场说不上好但也绝不算坏,想没想过那些煽风点火说iOS不行的人在做什么? 真的转行从头开始? 错.大错特错! 在劝退你的同时他们会 ...

  10. AcWing 1250. 格子游戏

    #include<bits/stdc++.h> using namespace std; int n,m; int fa[1000000]; int found(int x) { if(f ...