QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599750#8781. Element-Wise ComparisonericmegalovaniaCompile Error//C++201.6kb2024-09-29 10:16:372024-09-29 10:16:38

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 10:16:38]
  • 评测
  • [2024-09-29 10:16:37]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;

#define ONLINE
#ifndef ONLINE
char DEBUG_BUFFER[1000];
#define debug(...) {sprintf(DEBUG_BUFFER,##__VA_ARGS__);\
cerr<<"\033[1;36m"<<DEBUG_BUFFER<<"\033[0;2m"<<"\033[0m";}
#else
#define debug(...) ;
#endif

using LL=long long;
using PII=pair<int,int>;

#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

#define FAST_IO {ios::sync_with_stdio(false);cin.tie(nullptr);}
inline int read(){static int x; cin>>x; return x;}
inline LL readLL(){static LL x; cin>>x; return x;}
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

#define N 50001
int pos[N];
bitset<N>f[N],suf[M],tmp;

int main(){
	FAST_IO;
	int n=read(),m=read();
	for(int i=0;i<n;i++){
		pos[read()-1]=i;
	}
	tmp.reset();
	for(int x=n-1;x>=0;x--){
		f[pos[x]]=tmp>>pos[x];
		tmp[pos[x]]=1;
	}
#ifndef ONLINE
	for(int i=0;i<n;i++){
		debug("f[%d]=",i+1);
		cerr<<f[i]<<"\n";
	}
#endif
	LL ans=0;
	for(int i=0,last=-1;i<n-m+1;i++){
		if(i>last){
			last+=m;
			suf[0]=f[last];
			for(int j=1;j<m;j++){
				suf[j]=suf[j-1]&f[last-j];
			}
#ifndef ONLINE
			debug("update suf\n");
			debug("\tlast=%d\n",last);
			for(int j=0;j<m;j++){
				debug("suf[%d]=",j+1);
				cerr<<suf[j]<<"\n";
			}
#endif
			tmp.set();
		}
		ans+=(suf[last-i]&tmp).count();
		tmp&=f[i+m];
	}
	cout<<ans;
	return 0;
}

/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/

Details

answer.code:28:19: error: ‘M’ was not declared in this scope
   28 | bitset<N>f[N],suf[M],tmp;
      |                   ^
answer.code: In function ‘int main()’:
answer.code:51:25: error: ‘suf’ was not declared in this scope
   51 |                         suf[0]=f[last];
      |                         ^~~
answer.code:65:23: error: ‘suf’ was not declared in this scope
   65 |                 ans+=(suf[last-i]&tmp).count();
      |                       ^~~