QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#210875 | #7303. City United | vme50 | WA | 12ms | 40888kb | C++17 | 702b | 2023-10-11 20:54:18 | 2023-10-11 20:54:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define N 55
#define M 1600005
const int up=13;
int n,m,pw[N],e[N],o1[M],o2[M];bool ans,dp[N][M];
int main()
{
scanf("%d %d",&n,&m);pw[0]=dp[0][0]=1;
for(int i=1;i<=up;++i) pw[i]=pw[i-1]*3;
for(int i=1,u,v;i<=m;++i)
{scanf("%d %d",&u,&v);if(u<v) swap(u,v);e[u]|=1<<v-u+up;}
for(int i=0;i<pw[up];++i)
o1[i]=o1[i/3]<<1|(i%3==1),o2[i]=o2[i/3]<<1|(i%3==2);
for(int i=1;i<=n;++i) for(int j=0;j<pw[up];++j)
if(dp[i-1][j])
{
dp[i][j/3]^=1;
if(!(e[i]&o1[j])) dp[i][j/3+pw[up-1]*2]^=1;
if(!(e[i]&o2[j])) dp[i][j/3+pw[up-1]]^=1;
}
for(int i=0;i<pw[up];++i) if(o1[i]<o2[i]) ans^=dp[n][i];
printf("%d\n",ans);return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 22532kb
input:
3 2 1 2 2 3
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 4ms
memory: 22464kb
input:
3 3 1 2 2 3 3 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 12ms
memory: 40888kb
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:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'