QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686011 | #1869. Power Station of Art | 0xyz | WA | 400ms | 93740kb | C++14 | 2.0kb | 2024-10-28 22:58:07 | 2024-10-28 22:58:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int _=2e6+5;
int T,n,m,s,o,f[_],a[_],b[_],h[_],u[2][_],v[2][_],U[2][_],V[2][_];
char c[_],d[_];
vector<int>e[_];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
cin>>n>>m;s=1;
for(int i=1;i<=n;i++)e[i].clear(),f[i]=0;
for(int i=1,x,y;i<=m;i++)cin>>x>>y,e[x].push_back(y),e[y].push_back(x);
for(int i=1;i<=n;i++)cin>>a[i],h[i]=a[i];
for(int i=1;i<=n;i++)cin>>c[i];
for(int i=1;i<=n;i++)cin>>b[i],h[n+i]=b[i];
for(int i=1;i<=n;i++)cin>>d[i];
sort(h+1,h+n+n+1);o=unique(h+1,h+n+n+1)-h-1;
for(int i=1;i<=n;i++)a[i]=lower_bound(h+1,h+o+1,a[i])-h,b[i]=lower_bound(h+1,h+o+1,b[i])-h;
for(int i=1;i<=n;i++)
if(!f[i]){
int cu=(c[i]=='R'),cv=(d[i]=='R'),fl=1;
vector<int>w[2];
queue<int>q;
f[i]=1;u[0][a[i]]++;v[0][b[i]]++;
U[0][a[i]]+=(c[i]=='R');V[0][b[i]]+=(d[i]=='R');
w[0].push_back(i);q.push(i);
while(q.size()){
int x=q.front();q.pop();
for(auto y:e[x])
if(!f[y]){
f[y]=3-f[x];cu+=(c[y]=='R');cv+=(d[y]=='R');
u[f[y]-1][a[y]]++;
v[f[y]-1][b[y]]++;
U[f[y]-1][a[y]]+=(c[y]=='R');
V[f[y]-1][b[y]]+=(d[y]=='R');
w[f[y]-1].push_back(y);q.push(y);
}else if(f[y]==f[x])fl=0;
}
for(int o:{0,1})
for(int j:w[o])
if(u[0][a[j]]+u[1][a[j]]!=v[0][a[j]]+v[1][a[j]]||u[0][b[j]]+u[1][b[j]]!=v[0][b[j]]+v[1][b[j]])s=0;
if(cu%2!=cv%2)s=0;
if(fl){
for(int o:{0,1})
for(int j:w[0]){
if(U[0][a[j]]+u[1][a[j]]-U[1][a[j]]!=V[0][a[j]]+v[1][a[j]]-V[1][a[j]])s=0;
if(u[0][a[j]]-U[0][a[j]]+U[1][a[j]]!=v[0][a[j]]-V[0][a[j]]+V[1][a[j]])s=0;
if(U[0][b[j]]+u[1][b[j]]-U[1][b[j]]!=V[0][b[j]]+v[1][b[j]]-V[1][b[j]])s=0;
if(u[0][b[j]]-U[0][b[j]]+U[1][b[j]]!=v[0][b[j]]-V[0][b[j]]+V[1][b[j]])s=0;
}
}
for(int o:{0,1})
for(int j:w[o])u[o][a[j]]=v[o][b[j]]=U[o][a[j]]=V[o][b[j]]=0;
}
cout<<(s?"YES":"NO")<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 77140kb
input:
3 2 1 1 2 3 4 RR 4 3 BB 3 2 1 2 2 3 1 1 1 RBR 1 1 1 BBB 3 3 1 2 2 3 3 1 1 1 1 RBR 1 1 1 BBB
output:
YES NO YES
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 400ms
memory: 93740kb
input:
25054 5 10 4 5 4 2 4 3 4 1 5 2 5 3 5 1 2 3 2 1 3 1 12 2 9 10 7 RRRBB 10 2 9 7 12 RRBRB 1 0 4 R 4 R 8 4 4 3 1 5 8 5 6 5 7 2 11 10 9 6 3 5 RBRBBRBR 7 2 10 11 6 5 3 9 RBRBBRBR 7 4 7 2 5 1 5 6 5 4 12 5 9 14 5 12 12 RRBRBRR 14 12 9 5 12 12 5 RBBRBRB 10 1 4 6 5 3 2 9 7 3 11 11 6 8 RRRBRRBBBR 5 3 2 3 7 9 1...
output:
YES YES YES YES YES YES YES YES YES NO YES NO YES NO NO YES YES YES NO YES NO YES YES NO YES YES NO YES NO YES YES YES YES NO YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO NO YES NO YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO YES NO NO...
result:
wrong answer 3303rd lines differ - expected: 'NO', found: 'YES'