QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#584104 | #1869. Power Station of Art | TrueFalse | WA | 262ms | 31236kb | C++14 | 2.0kb | 2024-09-23 08:38:51 | 2024-09-23 08:38:51 |
Judging History
answer
/**
* @author TrueFalse
* @date 2024.9.20
* @version 1.1
*/
#include <bits/stdc++.h>
using namespace std;
using ci = const int;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
template<class T> inline void Max(T &x, const T &y) { if (x < y) x = y; }
template<class T> inline void Min(T &x, const T &y) { if (y < x) x = y; }
const int N = 5e5 + 5;
struct Map {
vector<int> e[N];
void addedge(int u, int v) {
e[u].push_back(v);
}
void clear(ci n) {
for (int i = 1; i <= n; ++i)
e[i].clear();
}
vector<int> &operator[](ci &x) { return e[x]; }
} E;
struct LSH {
multiset<int> mp;
void clear() { mp.clear(); }
void ins(ci &x) { mp.insert(x); }
bool operator!=(const LSH &o) const { return mp != o.mp; }
} H[2];
int T, n, m, a[2][N];
char str[2][N];
int tong[N];
int c[2][4];
bool dfs(int u, bool f) {
if (~tong[u]) return tong[u] == f;
tong[u] = f;
for (int k = 0; k < 2; ++k) {
++c[k][f ^ (str[k][u] == 'R')];
++c[k][2 + (str[k][u] == 'R')];
H[k].ins(a[k][u]);
}
for (ci &v : E[u]) if (!dfs(v, !f)) return 0;
return 1;
}
bool work() {
scanf("%d %d", &n, &m);
memset(tong, -1, sizeof(int) * (n + 1));
E.clear(n);
for (int i = 1, u, v; i <= m; ++i) {
scanf("%d %d", &u, &v);
E.addedge(u, v);
E.addedge(v, u);
}
for (int k = 0; k < 2; ++k) {
for (int i = 1; i <= n; ++i)
scanf("%d", &a[k][i]);
scanf("%s", str[k] + 1);
}
for (int i = 1; i <= n; ++i) {
if (!~tong[i]) {
H[0].clear(), H[1].clear();
memset(c, 0, sizeof c);
if (dfs(i, 0)) {
if (c[0][0] != c[1][0] or c[0][1] != c[1][1]) return 0;
} else {
if ((abs(c[0][2] - c[1][2]) ^ abs(c[0][3] - c[1][3])) & 1) return 0;
}
if (H[0] != H[1]) return 0;
}
}
return 1;
}
int main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
scanf("%d", &T);
while (T--) {
puts(work() ? "YES" : "NO");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 20444kb
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: 262ms
memory: 31236kb
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 YES YES NO YES NO NO YES YES YES NO YES NO YES NO NO YES YES NO YES NO NO YES YES NO NO NO YES NO NO NO YES YES NO NO NO NO YES YES NO NO YES YES NO NO NO NO YES NO NO YES NO YES YES YES YES YES NO YES NO YES YES NO YES NO YES YES YES NO YES NO NO NO YES YES YES N...
result:
wrong answer 10th lines differ - expected: 'NO', found: 'YES'