为啥博客园 \(\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. 每天凌晨 2:00 将 mysql 数据库 testdb ,备份到文件中。

    步骤:1, 首先编写一个 脚本 backupdb.sh#!/bin/bash #备份路径 BACKUP=/data/backup/sql/dy #当前时间 DATETIME=$(date +%Y-%m ...

  2. centos 7 能ping通但是telnet 22 不通解决方法

    试过关闭Linux防火墙,打开sshd服务,修改ens33为enth0.发现不好使. 经过不断的努力我发现,windows系统里面的VMware Network Adapter VMnet8设置的ip ...

  3. SCP,SSH应用

  4. Acwing Arithmetic Learning:数据结构(2)

    目录 数据结构(2)acwing 1.trie树 2.并查集(近乎O(1)) 3.堆 数据结构(2)acwing 1.trie树 快速存储和查找字符串的集合 结构特征: 例题:Trie字符串统计 ? ...

  5. 快速简单的了解VLAN(VXLAN)和端口链路类型

    目录 前言 一.VLAN是什么? 1.优点 2.为什么推出VXLAN 二.VXLAN又是什么? 1.优点 三.创建VLAN 四.介绍端口链路类型 五.Access 1.特性 六.Trunk 1.特性 ...

  6. 陋居寡闻,初探Github CLI For Windows,开启命令行撸铁时代

    简介 gh is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to t ...

  7. 6、inotify实时备份

    备份用户nfs共享文件系统,存储单点解决方案inotify+rsync(增量,无差异备份),inotify是单线程, inotify是一种强大的,细粒度的,异步的文件系统事件监控机制,通过加入了ino ...

  8. 基于uniapp自定义Navbar+Tabbar组件「兼容H5+小程序+App端Nvue」

    uni-app跨端自定义navbar+tabbar组件|沉浸式导航条|仿咸鱼凸起标签栏 在跨端项目开发中,uniapp是个不错的框架.采用vue.js和小程序语法结构,使得入门开发更容易.拥有非常丰富 ...

  9. Docker搭建Jenkins+Maven/Gradle——代码自动化运维部署平台(二)

    一.简介 1.Jenkins 概述: Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Jenkins ...

  10. 尝试用面向对象思维理解Vue组件

    什么是组件 用面向对象的思维去理解Vue组件,可以将所有的事物都抽象为对象,而类或者说是组件,都具有属性和操作. 如抽取人类为组件,其基本的属性有姓名.年龄.国籍:基本的方法有吃饭.睡觉.跑步等. & ...