今日份见鬼之“本地 CE ,提交 AC”
查看原帖
今日份见鬼之“本地 CE ,提交 AC”
335552
Christophe_楼主2022/7/22 11:33

RT,众所周知CF896E是一道可以用指令集暴力过的黑题,于是在同学的强烈推荐下蒟蒻尝试暴力水一水:

// Problem: CF896E Welcome home, Chtholly
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF896E
// Memory Limit: 500 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC opimize(1,2,3,"Ofast","inline","-ffast-math")
const int N=1e5+3;
int n,m,a[N],op,l,r,x;
namespace IO{
    template <class T> inline void read (T &x) { x = 0; bool f = 0; char ch = getchar (); while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar (); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar (); x = f ? ~x + 1 : x; }
    template <class T> inline void write (T x) { static char c[20]; unsigned p = 0; if (x < 0) putchar ('-'), x = ~x + 1; if (!x) { putchar ('0'); return ; } while (x) c[++p] = x % 10 ^ 48, x /= 10; while (p) putchar (c[p]), --p; }
    template <class T, class... U> inline void read (T &x, U &...t) { read (x), read (t...); }
    template <class T, class... U> inline void write (T x, U ...t) { write (x), write (t...); }
}
using namespace IO;
int ans=0;
int main(){
	read(n,m);
	while(n--) read(a[i]);
	while(m--){
		read(op,l,r,x);
		if(op==2){
			ans=0;
			for(register int j=l;j<=r;++j) ans+=a[j]==x;
			write(ans),putchar('\n');
		}else if(op==1){
			for(register int j=l;j<=r;++j) a[j]-=a[j]>x?x:0;
		}
	}
	return 0;
}

提交记录:80665644

但是在本地编译后:

27:20: error: 'i' was not declared in this scope 
  while(n--) read(a[i]); 

然后愕然发现,变量 i 压根就没有定义过,也没有自增过(不写 for 是为了卡常).

所以这份代码是怎么编译成功的?

即使过了编译,又是什么机制使得这份代码能够正常读取数据并 AC 呢?

2022/7/22 11:33
加载中...