QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#314149 | #7303. City United | zdczdc | WA | 72ms | 4844kb | C++20 | 1.0kb | 2024-01-25 13:30:48 | 2024-01-25 13:30:50 |
Judging History
answer
#include <bits/stdc++.h>
#define ALL(x) begin(x), end(x)
#define All(x, l, r) &x[l], &x[(r) + 1]
using namespace std;
void file(){
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
}
using ll = long long;
const int sMax = 4'782'969;
int n, m;
array<int, 16> pw;
array<vector<int>, 55> g;
bitset<sMax> f, tf;
int main(){
// file();
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
pw[0] = 1;
for(int i = 1; i <= 15; i++) pw[i] = 3 * pw[i - 1];
for(int i = 1, u, v; i <= m; i++){
cin >> u >> v;
if(u < v) swap(u, v);
g[u].push_back(v);
}
tf[0] = 1;
bool rs = 0;
for(int i = 0; i <= n; i++, tf = f){
f.reset();
for(int S = 0; S < sMax; S++){
if(!tf[S]) continue;
if((S % 3) == 1) rs ^= 1;
vector<int> cnt(3, 0);
for(int to : g[i + 1]) cnt[(S / pw[i - to]) % 3]++;
if(!cnt[2]) f[(S * 3 + 1) % sMax] = 1;
if(!cnt[1]) f[(S * 3 + 2) % sMax] = 1;
f[(S * 3) % sMax] = 1;
}
}
cout << rs << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 4832kb
input:
3 2 1 2 2 3
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 18ms
memory: 4756kb
input:
3 3 1 2 2 3 3 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 72ms
memory: 4724kb
input:
15 31 9 5 14 5 2 7 5 15 11 14 11 9 2 6 3 4 12 1 6 8 3 5 11 10 15 6 4 1 1 2 8 9 6 12 14 10 13 2 4 5 3 8 3 15 11 6 7 5 4 6 11 2 13 15 3 2 8 4 6 13 7 10
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 72ms
memory: 4776kb
input:
15 92 10 9 15 7 11 1 7 2 12 10 1 12 4 13 1 4 11 5 1 2 4 3 1 9 15 4 11 7 14 1 8 7 8 12 7 4 10 14 7 13 6 13 4 12 11 10 13 8 13 15 10 7 2 14 12 13 14 5 8 4 12 9 7 9 15 10 10 4 11 15 13 10 6 15 8 9 2 8 11 12 5 4 1 6 2 9 10 1 5 6 14 12 5 13 5 10 6 9 15 8 12 15 10 2 5 7 4 6 2 11 12 3 15 9 9 3 3 10 5 2 12 ...
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 70ms
memory: 4696kb
input:
15 80 5 10 10 13 13 4 4 2 6 10 8 6 13 7 13 9 9 5 6 13 6 3 13 14 10 12 8 3 8 13 9 1 7 5 14 6 14 10 6 9 11 14 7 10 13 15 7 9 14 7 8 1 10 3 11 6 15 7 12 8 3 13 6 2 6 7 13 5 7 3 11 8 3 5 2 5 15 2 7 12 1 14 11 1 1 10 10 4 4 14 2 9 12 5 15 8 8 5 1 13 1 12 9 14 14 2 1 3 14 5 10 15 3 15 1 7 1 5 6 15 8 9 2 7...
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: -100
Wrong Answer
time: 72ms
memory: 4844kb
input:
15 45 13 15 3 15 5 4 15 14 6 10 2 3 10 11 9 8 8 7 10 4 9 2 3 8 15 2 2 6 15 9 6 15 10 7 8 2 5 6 14 10 12 10 8 1 11 3 3 12 2 1 11 15 11 5 2 7 1 11 8 4 1 6 14 5 5 2 13 1 7 11 4 12 12 14 15 5 7 5 10 2 4 7 13 2 4 14 12 1 12 11
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'