QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#616629 | #1869. Power Station of Art | cyj888 | WA | 0ms | 5952kb | C++11 | 1.8kb | 2024-10-06 09:24:02 | 2024-10-06 09:24:02 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define ott(i, l, r) for (int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (int i = (r); i >= (l); i --)
int read () {
int x = 0; bool f = 0; char c = getchar ();
while (!isdigit (c)) f |= (c == '-'), c = getchar ();
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
if (f) x = -x; return x;
}
using namespace std;
using ll = long long;
const int N = 1e5 + 110, mod = 1e9 + 7, inf = 0x3f3f3f3f;
int T, n, m; bool res;
int a[N], b[N], col[N], c1[2], c2[2]; bool c[N], d[N];
vector <int> e[N];
vector <pair <int, int>> A, B;
bool dfs (int u) {
A.emplace_back (a[u], c[u] ^ col[u]), B.emplace_back (b[u], d[u] ^ col[u]);
bool fl = 1; ++ c1[c[u]], ++ c2[d[u]];
for (int v : e[u]) {
if (!~col[v]) col[v] = col[u] ^ 1, fl &= dfs (v);
else if (!(col[v] ^ col[u])) fl = 0;
}
return fl;
}
void sol () {
res = 1, n = read (), m = read (); while (m --) {
int x = read (), y = read ();
e[x].pb (y), e[y].pb (x);
}
ott (i, 1, n) a[i] = read (); ott (i, 1, n) c[i] = getchar () == 'R';
ott (i, 1, n) b[i] = read (); ott (i, 1, n) d[i] = getchar () == 'R';
fill (col + 1, col + 1 + n, -1);
ott (i, 1, n) {
if (!~col[i]) {
col[i] = 0, c1[0] = c2[0] = c1[1] = c2[1] = 0;
bool fl = dfs (i); sort (A.begin (), A.end ()), sort (B.begin (), B.end ());
if (fl)
ott (i, 0, A.size () - 1)
fl &= (A[i] == B[i]);
else {
fl = !((c1[0] ^ c2[0]) & 1);
ott (i, 0, A.size () - 1)
fl &= (A[i].fi == B[i].fi);
}
res &= fl, A.clear (), B.clear ();
}
}
puts (res ? "Yes" : "No");
ott (i, 1, n) e[i].clear ();
return ;
}
int main () {
T = read (); while (T --) sol ();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5952kb
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:
wrong answer 1st lines differ - expected: 'YES', found: 'Yes'