QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644103#8781. Element-Wise ComparisonyinheeWA 233ms920900kbC++141.7kb2024-10-16 10:56:122024-10-16 10:56:13

Judging History

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

  • [2024-10-16 10:56:13]
  • 评测
  • 测评结果:WA
  • 用时:233ms
  • 内存:920900kb
  • [2024-10-16 10:56:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>
	il void read(T &x){
		int f=1;x=0;char c=gc();
		while(c<'0'||c>'9'){
			if(c=='-'){
				f=-1;
			}
			c=gc();
		}
		while(c>='0'&&c<='9'){
			x=x*10+c-48,c=gc();
		}
		x*=f;
	}
	template<typename T,typename ...Args>
	void read(T &x,Args &...args){
		read(x),read(args...);
	}
	template<typename T>
	il void write(T x){
		char buf[43];int len=0;
		if(x<0){
			pc('-'),x=-x;
		}
		do{
			buf[++len]=x%10,x/=10;
		}while(x);
		while(len){
			pc(buf[len--]+'0');
		}
	}
}
using namespace my_std;
const int N=5e4+7,M=-1,inf=0x3f3f3f3f,mod=0;
#define L(i) (((i)-1)*m+1)
#define R(i) min((i)*m,n)
int n,m,a[N],p[N],id[N];
bitset<N> f[N],pre[N],suf[N];
void Yorushika(){
	read(n,m);
	rep(i,1,n){
		read(a[i]);
		a[i]=n-a[i]+1;
		p[a[i]]=i;
	}
	bitset<N> t;
	rep(i,1,n){
		f[i]=t>>p[i];
		t.set(p[i]-1);
	}
	rep(i,1,n){
		id[i]=(i-1)/m+1;
	}
	rep(i,1,id[n]){
		pre[L(i)]=f[L(i)];
		rep(j,L(i)+1,R(i)){
			pre[j]=pre[j-1]&f[j];
		}
		suf[R(i)]=f[R(i)];
		drep(j,R(i)-1,L(i)){
			suf[j]=suf[j+1]&f[j];
		}
	}
	int ans=0;
	rep(i,1,n-m+1){
		bitset<N> r;
		if(i==L(id[i])){
			r=pre[R(id[i])];
		}else{
			r=suf[i]&pre[i+m-1];
		}
		ans+=r.count();
	}
	printf("%d\n",ans);
}
signed main(){
	int t=1;
	//read(t);
	while(t--){
		Yorushika();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9996kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7892kb

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 9972kb

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

score: 0
Accepted
time: 0ms
memory: 8200kb

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

score: 0
Accepted
time: 1ms
memory: 7936kb

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Wrong Answer
time: 233ms
memory: 920900kb

input:

50000 2
44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...

output:

277220463

result:

wrong answer expected '310780127', found '277220463'