QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32737#1087. Brief Statements UnionWu_RenWA 2ms15944kbC++171.5kb2022-05-23 09:45:232022-05-23 09:45:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-23 09:45:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:15944kb
  • [2022-05-23 09:45:23]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int c[1000010],d[1000010],g[1000010],pre[1000010],suf[1000010];
int l[1000010],r[1000010],ls[1000010],rs[1000010],n,m;
bool can[1000010],ans[1000010];
ll x[1000010];
vector<int>v[2],cant;
int main(){
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++) scanf("%d%d%lld",&l[i],&r[i],&x[i]),ans[i]=1;
	for(int k=59;k<60;k++){
		v[0].clear(),v[1].clear(),cant.clear();
		for(int i=1;i<=n;i++) v[(x[i]>>k)&1].push_back(i);
		for(int i=1;i<=m;i++) c[i]=d[i]=0;
		for(int i:v[1]) d[l[i]]^=i,d[r[i]+1]^=i,c[l[i]]++,c[r[i]+1]--,ls[i]=m+1,rs[i]=0;
		for(int i=1;i<=m;i++) c[i]+=c[i-1],d[i]^=d[i-1],g[i]=g[i-1]+(c[i]==0);
		for(int i:v[0]) if(g[r[i]]-g[l[i]-1]==0) cant.push_back(i);
		if(!cant.size()) continue;
		if(cant.size()>1) for(int i:v[0]) ans[i]=0;
		else for(int i:v[0]) if(i^cant[0]) ans[i]=0;
		for(int i=1;i<=m;i++){
			if(c[i]==1) rs[d[i]]=i,pre[i]=i;
			else pre[i]=pre[i-1];
		}
		suf[m+1]=m+1;
		for(int i=m;i>=1;i--){
			if(c[i]==1) ls[d[i]]=i,suf[i]=i;
			else suf[i]=suf[i+1];
		}
		bool fl=1;
		int xl=1,xr=m;
		for(int i:cant){
			if(suf[l[i]]>r[i]){
				fl=0;
				break;
			}
			xl=max(ls[d[suf[l[i]]]],xl);
			xr=min(rs[d[pre[r[i]]]],xr);
		}
		if(!fl||xl>xr){
			for(int i:v[1]) ans[i]=0;
			continue;
		}
		for(int i=xl;i<=xr;i++) if(c[i]==1) can[d[i]]=1;
		for(int i:v[1]) ans[i]&=can[i];
		for(int i=xl;i<=xr;i++) if(c[i]==1) can[d[i]]=0;
	}
	for(int i=1;i<=n;i++) putchar(ans[i]+'0');puts("");
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 15944kb

input:

4 3
1 2 1
2 4 3
2 2 1

output:

111

result:

wrong answer 1st words differ - expected: '011', found: '111'