QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#63536 | #1869. Power Station of Art | lmeowdn | WA | 22ms | 155052kb | C++17 | 2.2kb | 2022-11-22 15:47:51 | 2022-11-22 15:47:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define eb emplace_back
#define y1 yylyylyylyyl
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef __int128 lll;
long long read() {
long long res=0, w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {res=res*10+c-48, c=getchar();}
return res*w;
}
const int N=1e6+9;
int T,n,m,col[N],sz[N],cnt,bp[N],a[N],b[N],bx[N],by[N];
vi e[N],s[N],sx[N],sy[N],gx[N],gy[N];
char t[N];
void dfs(int u,int c,int id) {
col[u]=c, s[id].eb(u), sz[id]++;
for(auto v:e[u]) {
if(col[v]!=-1) {
if(col[u]==col[v]) bp[id]=0;
} else dfs(v,c^1,id);
}
}
signed main() {
T=read();
while(T--) {
n=read(), m=read();
rep(i,1,n) col[i]=-1;
rep(i,1,m) {
int u=read(), v=read();
e[u].eb(v), e[v].eb(u);
}
rep(i,1,n) if(col[i]==-1) bp[++cnt]=1, dfs(i,0,cnt);
rep(i,1,n) a[i]=read();
scanf("%s",t+1);
rep(i,1,n) b[i]=(t[i]=='B');
rep(i,1,cnt) {
for(auto x:s[i]) sx[i].eb(a[x]), bx[i]^=b[x];
sort(sx[i].begin(),sx[i].end());
if(bp[i]) {
for(auto x:s[i]) gx[i].eb(b[x]^col[x]);
}
}
rep(i,1,n) a[i]=read();
scanf("%s",t+1);
rep(i,1,n) b[i]=(t[i]=='B');
rep(i,1,cnt) {
for(auto x:s[i]) sy[i].eb(a[x]), by[i]^=b[x];
sort(sy[i].begin(),sy[i].end());
if(bp[i]) {
for(auto x:s[i]) gy[i].eb(b[x]^col[x]);
}
}
bool ans=1;
rep(i,1,cnt) ans&=((sx[i]==sy[i])&(bx[i]==by[i])&(gx[i]==gy[i]));
if(ans) puts("YES");
else puts("NO");
rep(i,1,n) e[i].clear(), col[i]=-1, a[i]=b[i]=0;
rep(i,1,cnt) sz[i]=bp[i]=bx[i]=by[i]=0;
rep(i,1,cnt) s[i].clear(), sx[i].clear(), sy[i].clear(), gx[i].clear(), gy[i].clear();
cnt=0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 22ms
memory: 155052kb
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:
NO NO YES
result:
wrong answer 1st lines differ - expected: 'YES', found: 'NO'