QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#38699 | #1087. Brief Statements Union | Froggygua | WA | 4ms | 9744kb | C++17 | 1.2kb | 2022-07-07 10:19:07 | 2022-07-07 10:19:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 1000100
typedef long long ll;
int n,m,l[N],r[N],ans[N];
ll w[N];
void Solve(int z){
static int s[N],p[N],ok[N];
static int tot;
tot=0;
for(int i=1;i<=n;++i)s[i]=ok[i]=0;
for(int i=1;i<=m;++i){
if(w[i]>>z&1){
++s[l[i]],--s[r[i]+1];
}
}
for(int i=1;i<=n;++i){
s[i]+=s[i-1];
if(!s[i]){
ok[i]=1;
}
else if(s[i]==1){
p[++tot]=i;
}
}
for(int i=1;i<=n;++i){
ok[i]+=ok[i-1];
}
int liml=n,limr=1;
int jb=0,wei=0;
for(int i=1;i<=m;++i){
if(!(w[i]>>z&1)){
if(ok[r[i]]-ok[l[i]-1]>0)continue;
++wei,jb=i;
int L=lower_bound(p+1,p+tot+1,l[i])-p;
int R=upper_bound(p+1,p+tot+1,r[i])-p-1;
liml=min(liml,R),limr=max(limr,L);
}
}
for(int i=1;i<=m;++i){
if(w[i]>>z&1){
int L=lower_bound(p+1,p+tot+1,l[i])-p;
int R=upper_bound(p+1,p+tot+1,r[i])-p-1;
if(L>liml||R<limr){
ans[i]=0;
}
}
else{
if(wei>1||(wei==1&&jb!=i)){
ans[i]=0;
}
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=1;i<=m;++i){
cin>>l[i]>>r[i]>>w[i];
ans[i]=1;
}
for(int i=0;i<60;++i){
Solve(i);
}
for(int i=1;i<=m;++i){
cout<<ans[i];
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 9744kb
input:
4 3 1 2 1 2 4 3 2 2 1
output:
011
result:
ok "011"
Test #2:
score: 0
Accepted
time: 0ms
memory: 9732kb
input:
4 3 1 2 1 3 4 3 2 3 1
output:
111
result:
ok "111"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 9596kb
input:
8 8 1 3 23 2 8 8 2 4 10 3 3 26 1 3 26 1 4 10 4 7 8 4 5 40
output:
00000000
result:
wrong answer 1st words differ - expected: '10000000', found: '00000000'