QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#130163 | #6376. LaLa and Lamp | JWRuixi | RE | 1ms | 5600kb | C++17 | 1.6kb | 2023-07-23 17:23:16 | 2023-07-23 17:23:18 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
// #define ATC
#define LL long long
#define eb emplace_back
using namespace std;
#ifdef ATC
#include <atcoder/all>
using namespace atcoder;
#endif
typedef pair<int, int> pii;
#define fi first
#define se second
#define MP make_pair
const int maxn = 2005;
int n, a[maxn << 1];
char s[maxn][maxn];
bool vis[maxn];
vector<pii> G[maxn], R[maxn];
inline bool slv (int x, int y, int z) {
a[1] = z;
queue<int> q;
q.push(1);
while (!q.empty()) {
int u = q.front(); q.pop();
if (vis[u]) continue;
vis[u] = 1;
for (auto &[v, w] : G[u])
if (!vis[v])
a[v] = a[u] ^ x ^ w, q.push(v);
for (auto &[v, w] : R[u])
if (!vis[v])
a[v] = a[u] ^ y ^ w, q.push(v);
}
for (int i = 1; i <= n; i++) {
bool fl = (s[i][1] == '1') ^ a[n - i + 1] ^ a[n + 1];
for (int j = 2; j <= i; j++) if (((s[i][j] == '1') ^ a[n - i + j] ^ a[n + j]) != fl) return 0;
}
return 1;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> s[i] + 1;
for (int i = 1; i < n; i++) {
int v = s[n - 1][i] == '1';
G[i + 1].eb(MP(i + n, v));
G[i + n].eb(MP(i + 1, v));
}
for (int i = 1; i <= n; i++) {
int v = s[n][i] == '1';
R[i].eb(MP(i + n, v));
R[i + n].eb(MP(i, v));
}
bool fl = 0;
for (int x = 0; x < 2 && !fl; x++)
for (int y = 0; y < 2 && !fl; y++)
for (int z = 0; z < 2 && !fl; z++) {
memset(a, 0, 2 * n + 1 << 2);
fl |= slv(x, y, z);
}
puts(fl ? "Yes" : "No");
}
// I love WHQ!
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
6 0 00 000 0110 00100 000000
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
2 0 11
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
3 1 10 011
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
4 1 11 101 0101
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
5 0 11 010 0011 11100
output:
No
result:
ok answer is NO
Test #6:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
6 0 10 100 1011 00001 010101
output:
No
result:
ok answer is NO
Test #7:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
7 0 01 101 0010 11000 010100 0111101
output:
No
result:
ok answer is NO
Test #8:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
8 0 01 100 1111 10011 001010 1000010 00001101
output:
No
result:
ok answer is NO
Test #9:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
9 1 00 111 0000 11110 100011 0100101 01010001 010111101
output:
No
result:
ok answer is NO
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
10 1 01 011 1101 01011 000111 1111000 11111111 000010010 0011001100
output:
No
result:
ok answer is NO
Test #11:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
11 1 11 001 0001 00011 111000 1101001 10100101 100111110 1000001011 11110011111
output:
No
result:
ok answer is NO
Test #12:
score: 0
Accepted
time: 0ms
memory: 5600kb
input:
12 0 01 111 0101 01110 011000 1001010 10010001 011011000 1110110101 10101101110 111100100111
output:
Yes
result:
ok answer is YES
Test #13:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
13 0 00 010 0011 11101 101000 0000011 00101011 010000100 0100100100 10001100100 011011100100 1110000011011
output:
No
result:
ok answer is NO
Test #14:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
14 0 01 111 1111 01101 011000 0101111 00001110 011011001 1110000010 00111000101 110010101011 1100100011001 11001011100011
output:
No
result:
ok answer is NO
Test #15:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
15 0 10 011 0111 10100 000011 0010100 11100010 111000001 1111001011 11111110000 000110001111 0011101111100 11001101011011 010100101111110
output:
No
result:
ok answer is NO
Test #16:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
16 0 11 101 1000 01100 100010 1101111 01110101 010001000 0000110011 10011110010 101001000101 1011011111100 11110000011011 110000010111010 0111001011100110
output:
No
result:
ok answer is NO
Test #17:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
17 0 11 110 0110 10110 110111 0110100 01001100 010111101 0101011110 01010011000 010110010101 1010111110001 01010000111000 001011110101010 0110111101110000 01001111011000101
output:
No
result:
ok answer is NO
Test #18:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
18 1 01 100 0011 00100 001011 0100100 11011011 100100101 1100100111 01100100011 010011010101 1010011000110 11010011100001 011010010101111 0100101111001100 00000101011110101 011011011101111000
output:
No
result:
ok answer is NO
Test #19:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
19 0 10 110 0011 01001 110110 1000111 10010001 100001000 1111000001 01110010000 101100100001 1100001100110 01010000101000 010101111011111 0100000100110111 00111110110001000 111110010011000001 1010011010101000101
output:
No
result:
ok answer is NO
Test #20:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
20 1 01 000 1100 01011 011010 1111001 11000001 110110000 0010101100 01010010101 000100011000 1100110111101 01011111001100 011010001011101 1111001101110111 01000001011011101 100110000110001001 0000101100011011110 01000010101001110001
output:
No
result:
ok answer is NO
Test #21:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
2 0 00
output:
Yes
result:
ok answer is YES
Test #22:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
3 1 11 010
output:
Yes
result:
ok answer is YES
Test #23:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
4 1 10 000 0100
output:
Yes
result:
ok answer is YES
Test #24:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
5 0 11 011 1100 01111
output:
No
result:
ok answer is NO
Test #25:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
6 1 00 100 1101 00101 000110
output:
No
result:
ok answer is NO
Test #26:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
7 1 10 000 1011 00011 001101 0101111
output:
Yes
result:
ok answer is YES
Test #27:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
8 1 11 101 0010 00001 011001 0110111 00100011
output:
No
result:
ok answer is NO
Test #28:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
9 1 00 010 1010 10000 000100 1001110 10000111 010000110
output:
No
result:
ok answer is NO
Test #29:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
10 0 11 101 1110 11001 100100 0011001 11111100 101111111 1000100100
output:
No
result:
ok answer is NO
Test #30:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
11 0 10 000 0111 10000 100101 1110011 00110010 000100110 1000001110 10100110001
output:
No
result:
ok answer is NO
Test #31:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
12 0 01 110 0101 01001 010110 1001000 11110111 101101110 0011011110 01000100011 110011101100
output:
No
result:
ok answer is NO
Test #32:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
13 1 11 011 0101 10110 101111 0011110 10000000 101000011 0101111010 11000110111 000000101101 1001111100111
output:
No
result:
ok answer is NO
Test #33:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
14 0 00 011 0010 01111 101010 0111010 00110101 000011111 0110110101 11011000000 111110110100 0001011100010 00011110110001
output:
No
result:
ok answer is NO
Test #34:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
15 1 11 101 1110 10110 000110 1011000 01100101 000011110 0011101000 10100000100 100100100011 0000101101100 11000111110011 010111100110010
output:
Yes
result:
ok answer is YES
Test #35:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
16 0 00 011 0111 00101 001001 0111011 11101100 111110111 0101001100 01111101110 011001100010 1111101101000 01000001111010 001011010100010 1010100000110110
output:
No
result:
ok answer is NO
Test #36:
score: 0
Accepted
time: 1ms
memory: 5584kb
input:
17 1 11 000 1110 11100 011000 1000100 00101000 010111100 1010111100 10011101010 000101101110 1010001001000 01010111111000 101111111100010 0110011111011001 00010001100110101
output:
No
result:
ok answer is NO
Test #37:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
18 1 10 100 0100 00101 011010 0101111 01000101 111110100 1011110100 01011011001 100000101000 0011010000001 01111111111000 100111100101110 1111110010101100 00001111111100101 110101111011010111
output:
No
result:
ok answer is NO
Test #38:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
19 0 00 001 1011 01111 000111 0010110 00110110 010001010 1000011101 10011111100 100100011110 0010100100101 11101010101101 101010110111101 0000101110011101 00100100000100010 001100111101011101 0100011111001011100
output:
No
result:
ok answer is NO
Test #39:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
20 1 00 000 1011 01011 001001 1101110 11110111 111101111 0011010111 00100011100 000011101100 1101111001110 10111000100110 000011111101101 1011010110101001 01001011001110110 101011000010001000 1100011010001011010 00001101111100100000
output:
No
result:
ok answer is NO
Test #40:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 1 01
output:
Yes
result:
ok answer is YES
Test #41:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
3 1 00 101
output:
Yes
result:
ok answer is YES
Test #42:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
4 1 01 110 0110
output:
Yes
result:
ok answer is YES
Test #43:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
5 0 00 000 1110 11100
output:
Yes
result:
ok answer is YES
Test #44:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
6 0 11 101 0101 00101 110011
output:
No
result:
ok answer is NO
Test #45:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
7 1 11 011 0110 01111 110101 1000001
output:
No
result:
ok answer is NO
Test #46:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
8 1 10 100 0010 11110 011000 1101010 11110000
output:
No
result:
ok answer is NO
Test #47:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
9 0 00 100 1101 01110 010110 0011000 00000100 100111100
output:
Yes
result:
ok answer is YES
Test #48:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
10 0 10 000 1011 10100 001110 0000101 00010010 100111101 0101100011
output:
No
result:
ok answer is NO
Test #49:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
11 1 10 100 0100 00101 110001 0000001 10001111 010010011 0101010101 00100100111
output:
No
result:
ok answer is NO
Test #50:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
12 0 00 001 1010 00110 101110 1111110 10100001 011100000 0001100011 10101100100 001101101011
output:
No
result:
ok answer is NO
Test #51:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
13 1 11 011 1111 01000 110101 1100011 11001010 000011010 0001011000 00000111010 011100001111 1011010010100
output:
No
result:
ok answer is NO
Test #52:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
14 1 00 111 0100 00001 110110 0011000 00000111 101010011 1100110100 01000001000 111000010001 0010111000110 01111000110100
output:
No
result:
ok answer is NO
Test #53:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
15 1 01 001 1100 11100 100111 1100010 11010011 000011010 0111100100 10100001101 000101111011 0001011100111 01101110110110 100010011010110
output:
No
result:
ok answer is NO
Test #54:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
16 0 00 110 1101 10011 100110 0000111 11001000 101010110 1001101010 00000010010 101100011100 1001011111111 00000000111001 010011010110101 1110100110101100
output:
No
result:
ok answer is NO
Test #55:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
17 1 01 100 0111 00001 110011 0010110 00100011 101001001 0110011101 00000110101 001101100101 0010111000101 01011101111011 100110111111001 0111100011111101 01110110100001011
output:
Yes
result:
ok answer is YES
Test #56:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
18 0 10 000 1100 11010 110111 0010010 00100110 010110001 1001100000 00000111100 010010000100 0001000001010 10111100010110 011010100101110 1000000101011110 01110100110111110 111100011110000001
output:
Yes
result:
ok answer is YES
Test #57:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
19 0 01 100 1110 11100 011000 0110001 00010000 010100010 0010110110 10001000101 101010010011 1010000110101 00010001111000 100010001110100 1000110001111010 10011011100101011 101011111100110101 1000110110001110010
output:
No
result:
ok answer is NO
Test #58:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
20 1 00 011 0101 10111 110010 0000110 00010001 000111110 0110011111 11011011101 011110100110 1101010101100 01111101000101 110101101101000 1000001100110011 10101001110000100 101111101011101011 1011011000000111101 00110011010110001000
output:
No
result:
ok answer is NO
Test #59:
score: -100
Runtime Error
input:
1950 1 01 100 1000 01111 111110 0011100 00100110 101010011 0110111000 10001101110 100000111101 0000010011010 11000111010100 001001101001001 1101011001110011 11010001111111000 010100100011101111 0110110000100111111 10001100110101100000 011111001010111011110 1000010010010010100011 00000111011100110100...