CQ NOIp2021 代码疑惑行为大赏
LittleYang0531 · · 个人记录
前言
更佳的阅读体验: LittleYang0531 | C++编程萌新一枚
CQ 源码地址: LittleYang0531/CQ-NOIP-2021 - Github
建议再去看看两位比我搞的快的大神做的:
CQ NOIP 奇人合集(暗杀名单 - LEMON_ni 的蒟蒻种植基地 - 洛谷博客
CQ NOIP 奇人大赏 - 众所周知 XSC062 就是个 laoer - 洛谷博客
总结
CQ 市的 OIer 们一共写了 1225 份代码
包含了 3190 个 freopen (其中有 771 个是 CQ-0230 一位同学提供的),26 个文件流,2277 个 include 和 857 个万能头
44 分代码长度大于了 5KB,8 份代码长度大于了 1MB,甚至有一份代码 (CQ-0111) 长度达到了 19.1MB (硬生生打了 19MB 的表)
顺带一提,这次 NOIP 整活的同学相比 CSP-S 明显增多 (从关键词 fxck 和 love 的搜索结果可以看出)
奇人共赏
备注:
本机配置: 高通骁龙 765G,内存 8GB
本机系统: Debian 10 GNU/Linux aarch64
编译参数: g++ xxx.cpp -std=c++14 -O2 -lm -o xxx
编译结果仅供参考
文件大小相关
长话短说 (反正 Github 也显示不出来),就不贴图了
CQ-0248 number.cpp 427KB: 把部分合法的数全部打了个表
CQ-0316 number.cpp 5.7MB: 同样是打表,只不过比 CQ-0248 打的多
CQ-0330 chess.cpp 1.89MB: 没看懂在干什么
CQ-0309 number.cpp 587KB: 把小于等于
CQ-0111 number.cpp 19.1MB: 把所有数的合法性打了一遍
CQ-0109 number.cpp 15.4KB: 把不合法的数打了个表
CQ-0133 number.cpp 20.1KB: 同 CQ-0309,而且他还打到了
CQ-0118 number.cpp 6.44MB: 同 CQ-0316
CQ-0020 chess.cpp 13KB: 写了一堆总结,还有自己写的正解代码,最后炸了,换了个暴力,正解注释掉了
CQ-0121 number.cpp 5.78MB: 同 CQ-0316
CQ-0118 variance.cpp 240KB: 不知道在干啥
CQ-0119 number.cpp 682KB: 直接把结果表打了出来 (包括 -1 的那种)
CQ-0084 number.cpp 698KB: 同 CQ-109
CQ-0129 chess.cpp 1.92MB: 同样没看懂在干什么
CQ-0233 variance.cpp 14.1MB: 太大了 Dev-C++ 还打不开
CQ-0130 number.cpp 36.6KB: 同 CQ-0109
CQ-0128 number.cpp 5.7MB: CQ-0316
CQ-0205 chess.cpp 14KB: 同样没看懂在干什么。也许是在报复 CCF?
不文明行为
额...... 下一个
脏话连篇人
卖萌人 + 脏话连篇人
AKNOIP 人 + 手动划重点人
神志不清人 (@€€£)
老熟人 + 劈腿人?
文件相关
恶搞人 + 自爆人 + 不文明人 (这位同学写了 771 个 freopen,注释掉了 763 个)
顺带一提,这次 NOIp 没有注释掉文件的人 (除了恶搞的 + 样例人)
代码表白
新概念表白人 + 不文明人
表白 NOIp 人 + 不文明人 + 流泪人
老熟人 + 互相表白人 (终于知道Xiaoting是谁了)
AFO 相关
永不言弃人 + 不文明人
被卡常虐爆人 + 退役人 (图为其代码全部内容)
这是一个悲伤的故事......
代码错误相关
备注: 括号内数字为该份代码的错误行数
#include<bits/stdc++.h>
using namespace std;
int T,n,m,q;
string a1[200005],a2[200005];
struct node
{
int col,lv,x,y;
}a[1000005];
map<int,int>mp[200005];
string b[200005];
struct nood
{
int x,y,lim1,lim2;
};
int dx[5]={0,0,0,-1,1};
int dy[5]={0,1,-1,0,0};
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>T;
while(T--)
{
cin>>n>>m>>q;
for(int i=1;i<=n;i++)cin>>a1[i];
for(int i=1;i<n;i++)cin>>a2[i];
for(int i=1;i<=q;i++)
{
cin>>a[i].col>>a[i].lv>>a[i].x>>a[i].y;
cout<<bfs(a[i].x)<<'\n';
mp[a[i].x][a[i].y=i;
}
}
}
BFS 人(30) + 括号不匹配人(31) (来自 CQ-0064)
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0;
char c=getchar();
while(c<'0'||c>'9')
{
c=getchar();
}
while(c>='0'&&c<='9')
{
x=x*10+(c^48);
c=getchar();
}
return x;
}
const long long mod=998244353;
long long p[31];
int n,m,k;
int v[101];
long long ans;
long long res;
inline void dfs(int now,long long sum,int t)
{
//cout<<now<<" "<<sum<<" "<<t<<endl;
if(t==n)
{
int cnt=0;
while(sum)
{
cnt+=sum%2;
sum/=2;
if(cnt>k)
{
return ;
}
}
ans=(ans+res)%mod;
return ;
}
if(now>m)
{
return ;
}
for(int i=t;i<=n;i++)
{
res+=v[now]*(i-t);
dfs(now+1,sum+p[now]*(i-t),i);
res-=v[now]*(i-t);
}
return ;
}
int main()
{
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
p[0]=1;
for(int i=1;i<=100;i++)
{
p[i]=p[i-1]*2;
}
n=read();
m=read();
k=read();
for(int i=0;i<=m;i++)
{
v[i]=read();
}
dfs(0,0,0);
printf("%lld",ans);
return 0;
}
long long 存
......
long long ans,suma=0,sumsa=0;
for(int i=1;i<=n;i++) a[i]=read(),suma+=a[i],sumsa+=a[i]*a[i];
long long ada=a[1]+a[n]>>1;
for(int j=1;j<=n;j++) if( abs(ada-a[tem]) > abs(ada-a[j]) ) tem=j;
ans=(long long)n*sumsa-suma*suma;
for(int i=1;i<=n+1;i++)
{
for(int j=2;j<=n-1;j++)
{
long long x=a[j-1]+a[j+1]-a[j];
if( (long long)n*(sumsa+x*x-a[j]*a[j])-(suma+x-a[j])*(suma+x-a[j]) < (long long)n*sumsa-suma*suma )
{
sumsa+=x*x-a[j]*a[j];
suma+=x-a[j];
a[j]=x;
ans=min(ans,(long long)n*sumsa-suma*suma);
}
}
for(int j=n-2;j>=2;j--)
{
long long x=a[j-1]+a[j+1]-a[j];
if( (long long)n*(sumsa+x*x-a[j]*a[j])-(suma+x-a[j])*(suma+x-a[j]) < (long long)n*sumsa-suma*suma )
{
sumsa+=x*x-a[j]*a[j];
suma+=x-a[j];
a[j]=x;
ans=min(ans,(long long)n*sumsa-suma*suma);
}
}
}
for(int i=1;i<=n+1;i++)
{
for(int j=2;j<=n-1;j++)
{
long long x=a[j-1]+a[j+1]-a[j];
// if( (long long)n*(sumsa+x*x-a[j]*a[j])-(suma+x-a[j])*(suma+x-a[j]) < (long long)n*sumsa-suma*suma )
// {
sumsa+=x*x-a[j]*a[j];
suma+=x-a[j];
a[j]=x;
ans=min(ans,(long long)n*sumsa-suma*suma);
// }
}
}
printf("%d",ans);
......
类型不对应人其一(最后一行) (来自 CQ-0076)
int ans=0;
for(int S=n;S<=maxx;S++){
if(check(S)){
ans=(0ll+dp[m][n][S]+ans)%mo;
}
}
printf("%lld\n",ans);
类型不对应人其二(最后一行) (来自 CQ-0096)
......
long long num=1,ans;
int ll[500];
bool guo[maxn];
......
for(long long i=n;i<=n*num;i++)
{
kk=0;
memset(ll,0,sizeof(ll));
if(!erj(i)) continue;
dfs(0,0);
}
printf("%d",ans);
......
类型不对应人其三(最后一行) (来自 CQ-0114)
for(int j=1;j<=q;j++)
{
scanf("%d%d%d%d",zfc[j].col,zfc[j].lv,zfc[j].x,zfc[j].y);
bfs(zfc[j].x,zfc[j].y);
}
类型不对应人其四(3) (来自 CQ-0141)
......
LL ans = 0;
for(int j = 0; j <= k; j++){
for(int rp = 0; rp < 16; rp++){
ans = (ans + dp[m][n][j][rp]) % kkk;
}
}
printf("%d", ans);
return 0;
......
类型不对应人其五(7) (来自 CQ-0152)
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],ans,sum;
int main(){
freopen("variance.in","r",stdin);
freopen("variance.out","w",stdout);
scanf("%lld",&n);
for(long long i=1;i<=n;i++){
scanf("%lld",&a[i]);
sum+=a[i];
}
if(n==1){
printf("0\n");
return 0;
}
if(n==2){
printf("%d\n",n*a[1]*a[1]+n*a[2]*a[2]-sum*sum);
return 0;
}
......
类型不对应人其六(17) (来自 CQ-0153)
#include<bits/stdc++.h>
using namespace std;
const int N=10005;
int n,a[N];
bool dp[1005][1005];
int ans=2147483647;
void dfs(int a2,int a3) {
if (dp[a2][a3]) return;
dp[a2][a3]=1;
ans=min(ans,4*(a[1]*a[1]+a2*a2+a3*a3+a[4]*a[4])-(a[1]+a2+a3+a[4])*(a[1]+a2+a3+a[4]));
dfs(a[1]+a3-a2,a3);
dfs(a2,a[4]+a2-a3);
return;
}
int main() {
freopen("variance.in","r",stdin);
freopen("variance.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++) {
scanf("%lld",&a[i]);
}
......
类型不对应人其七(20) (来自 CQ-0167)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e4+5;
int n;
ll a[N],ans;
int main(){
freopen("variance.in","r",stdin);
freopen("variance.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
......
类型不对应人其八(12) (来自 CQ-0185)
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5,mod=998244353;
int n,m,k;
bool vis[M];
long long ans,sum,a[M];
bool check(long long x){
int tot=0;
for(int i=0;i<=25;i++){
if(x&(1ll<<i)){
tot++;
}
}
if(tot>k) return 0;
return 1;
}
void dfs(int x,long long sum,long long p){
if(x==n+1){
if(check(sum)){
ans+=p;
ans%=mod;
}
return;
}
for(int i=0;i<=m;i++){
dfs(x+1,sum+(1<<i),p*a[i]%mod);
}
}
/*bool check(node l,node r){
if(n*(2*r.y-l.x+r.x)*(r.x-l.x)<2*sum+r.x-l.x){
return 1;
}
return 0;
}*/
int main(){
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
// ans=1e18;
scanf("%d %d %d",&n,&m,&k);
for(int i=0;i<=m;i++){
scanf("%d",&a[i]);
}
类型不对应人其九(41) (来自 CQ-0186)
#include<bits/stdc++.h>
using namespace std;
int n,a[10005];
int main()
{
freopen("variance.in","r",stdin);
freopen("variance.out","w",stdout);
scanf("%d",n);
for(int i=1; i<=n; ++i) scanf("%d",a[i]);
return 0;
}
类型不对应人其十(8,9) (来自 CQ-0192)
#include<bits/stdc++.h>
using namespace std;
bool is_prime[20000003];
long long Num[20000003];
int tot;
bool check(int x){
bool flag=false;
while(x){
int ans=x%10;x/=10;
if(ans==7)flag=true;
}
return flag;
}
int main(){
freopen("number.in","r",stdin);
freopen("number.out","w",stdout);
for(int i=1;i<=10000020;i++){
if(Num[tot]>10000000)break;
if(is_prime[i])continue;
if(check(i)){
is_prime[i]=1;
for(int j=2*i;j<=10000020;j+=i)is_prime[j]=1;
}
if(!is_prime[i])Num[++tot]=i;
}
int T;
cin>>T;
while(T--){
int x;scanf("%d",&x);
int now=lower_bound(Num+1,Num+tot+1,x)-Num;
if(Num[now]!=x)printf("-1\n");
else{
printf("%d\n",Num[now+1]);
}
}
return 0;
}
类型不对应人其十一(33) (来自 CQ-0193)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
srand(time(0));
printf("%lld",rand()%998244353);
}
类型不对应人其十二(9) + 随机人(9) (来自 CQ-0194)
......
long long a[105],b[105];
long long ans=0;
bool q[35];
......
dfs1(q,k,0);
printf("%d",ans);
......
类型不对应人其十三(5) (来自 CQ-0195)
......
int N,A[Maxn],ans=INF,K=100;
......
void Solve2(){
while(K--) fire();
printf("%lld",ans);
}
......
类型不对应人其十四(5) (来自 CQ-220)
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
long long ans;
long long v[105];
int read()
{
int num,f = 1;
char ch;
while((ch = getchar()) && (ch < '0' || ch > '9'))
{
if(ch == '-') f = -1;
}
num = ch - '0';
while((ch = getchar()) && (ch >= '0' && ch <= '9')) num = num * 10 + ch - '0';
return num * f;
}
void print(int x)
{
if(x < 0) putchar('-'),x *= -1;
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
}
bool check(int num)
{
// cout<<num<<':'<<endl;
int sum = 0;
while(num)
{
sum += (num & 1);
num /= 2;
// cout<<sum<<endl;
if(sum > k) return true;
}
return false;
}
void dfs(int k,int sum,long long num)
{
// cout<<k<<' '<<sum<<endl;
num %= 998244353;
if(k == n + 1)
{
if(!check(sum)) ans += num;
ans %= 998244353;
return;
}
long long f = 1;
for(int i = 0 ; i <= m ; i++)
{
dfs(k + 1,sum + f,num * v[i]);
f *= 2;
}
}
int main()
{
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
cin>>n>>m>>k;
for(int i = 0 ; i <= m ; i++)
{
scanf("%d",&v[i]);
}
dfs(1,0,1);
cout<<ans;
return 0;
}
类型不对应人其十五(61) (来自 CQ-226)
...... 同样还有此错误的还有 CQ-0245,CQ-0251,CQ-0258,CQ-0276,CQ-0284,CQ-0291,CQ-0301,CQ-0304,CQ-0307,CQ-0326,CQ-0331 (我不想打了)
顺带一提,在 Linux 里出现这样的错误是很有可能爆零的
struct node{
bool ATP[111];//S的二进制数
int Num[31];//选择的ai
int One;//1的个数
add(int a)
{
if(ATP[a])
add(a+1),ATP[a]=0,One--;
else
ATP[a]=1,One++;
}
}K;
无类型人(5) (来自 CQ-0084)
......
const int N = 1e4;
const int M = 1e4;
int n, m, q, x0, y0;
int opt[N][M][2], color[N][M], level[N][M];//opt[i][j][0]横向 opt[i][j][1]纵向
bool vis[N][M], end[N][M];
int moves(int x, int y, int r, int t) //r:道路种类 //t:(r=1)t=0未走(r=2)t=0未确定方向t=1横向t=2纵向(t=3)无意义
{
vis[x][y] = 1;
int ans = end[x][y] ? 0 : 1;
end[x][y] = 1;
if(y<m){
......
终结者其一(6) (来自 CQ-0094)
......
int pan[605];
int hand,end;
int b[405];
int c[405];
......
终结者其二(2) (来自 CQ-0145)
......
bool vis[10000005];
int sum[10000005],cnt;
int next[10000005];
int main()
{
freopen("number.in","r",stdin);
freopen("number.out","w",stdout);
for(int i = 1 ; i <= 10000000 ; i++)
{
......
下一位其一(3) (来自 CQ-0226)
#include<bits/stdc++.h>
using namespace std;
const int MAX=10000500;
int next[MAX];
int N;
int read(){
......
下一位其二(4) (来自 CQ-0279)
......
return (int)(n*ans);
}
int hash() {
int res=0;
for(int i=1;i<=n;++i) res=res*ha+a[i];
return res;
}
void dfs() {
int k=hash();
if(mp.find(k)==mp.end()) mp[k]=1,res=min(res,solve());
......
哈希人其一(3) (来自 CQ-0250)
#include<bits/stdc++.h>
using namespace std;
int a[30],b[30],base=233;
int hash[1000001],mod=1000001;
int main() {
freopen("variance.in","r",stdin);
freopen("variance.out","w",stdout);
......
哈希人其二(4) (来自 CQ-0315)
/*
The last 20 minutes.The last 20 minutes of my OI road.
I couldn't type any codes out right now(even a violent code),
maybe I also wouldn't make it any other time.
I started with the success of "a+b Problem",
and end up with the complete failure in NOIP 2021.
I just like Faust,didn't cried out"You are so beautiful,please slow down!" until he is dying.
Now,I just want to close my eyes,and enjoy counting the few secounds remained,
because it must be the last time I join in OI competetion.
However,I won't just give OI up,I still believe that I just have to leave it for a short time.
Maybe as soon as I go to the college,I'll pick it up again.
At last,wish you good luck,the stranger before the screen.Don't give OI up so easily as me,you are intelligent enough to make a legend.
--Demon King
*/
老朋友 (来自 CQ-0109) (CSP-S 的迷惑行为出现过)
#include<cstdio>
#include<iostream>
using namespace std;
freopen("variance.in", "r", stdin);
freopen("variance.out", "w", stdout);
int main(){
cout << "52" << endl;
return 0;
}
文件人(4,5) (来自 CQ-0140)
......
bool vis[5005][5005];
int main() {
froeenp("chsse.in", "r", stidn);
......
stidn人 + froeenp人 + chsse 人(4) (来自 CQ-0190)
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
int penguin[100000005],watermelon[15][15][15][15][15][15][15];
using namespace std;
signed main() {
freopen("chess.jpg","r",stdin);
freopen("chess.mp3","w",stdout);
while(true) cout << "Luckily" << endl;
......
恶搞人(6,7) (来自 CQ-0205)
//Nerver gOnna gIve you uP
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=,mod=998244353;
inline void read(int &x){
x=0;int f=1;char ch=getchar();
while(!isdigit(ch)){
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch)){
x=x*10+(ch^48);
ch=getchar();
}
x*=f;
}
int main(){
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
return 0;
}
没值人(5) + NOIP 人(1) (来自 CQ-0142)
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
//vector<int> a[2600],b[2600];
...
Windows 人(2) (来自 CQ-0233)
#include <map>
#include <cstdio>
using namespace std;
map<int [1000],int >mp;
int a[1000]={1,2,3,4,5};
int main(){
mp[a]=1;
}
奇怪错误(4)(来自 CQ-237)
......
while(T--){
memset(hed,0,sizeof(hed));
memset(nxt,0,sizeof(nxt));
memset(yd,0,sizeof(nxt));
scanf("%d%d%d",&n,&m,&Q);
for(int i=1;i<=n;i++){
......
memset 了个寂寞(4) (来自 CQ-0253)