QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123175 | #6413. Classical Graph Theory Problem | c20230537 | WA | 1119ms | 7388kb | C++14 | 1.1kb | 2023-07-11 20:35:18 | 2023-07-11 20:35:19 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b) for(ll i=(a);i>=(b);--i)
#define Yes printf("Yes\n")
#define No printf("No\n")
#define pb emplace_back
const ll N=1000+10;
using namespace std;
mt19937 rd(time(0));
ll n,m;
vector<ll>e[N];
ll a[N],b[N];
ll vis[N];
ll t[N][2];
ll ans;
void f(ll x){
ans-=!t[x][vis[x]^1];
for(ll y:e[x])ans-=!t[y][vis[y]^1],--t[y][vis[x]];
vis[x]^=1;
ans+=!t[x][vis[x]^1];
for(ll y:e[x])++t[y][vis[x]],ans+=!t[y][vis[y]^1];
}
void mian(){
scanf("%lld%lld",&n,&m);
a[0]=b[0]=0;
For(i,1,m){
ll x,y;
scanf("%lld%lld",&x,&y);
e[x].pb(y),e[y].pb(x);
}
For(i,1,n){
if(i&1)b[++b[0]]=i,vis[i]=1;
else a[++a[0]]=i,vis[i]=0;
}
For(x,1,n){
for(ll y:e[x])++t[x][vis[y]];
ans+=!t[x][vis[x]^1];
}
while(ans){
ll x=rd()%a[0]+1,y=rd()%b[0]+1;
ll tmp=ans;
f(a[x]),f(b[y]);
if(tmp<ans)f(a[x]),f(b[y]);
else swap(a[x],b[y]);
}
For(i,1,a[0])printf("%lld ",a[i]);
printf("\n");
}
int main(){
int T=1;
scanf("%d",&T);
while(T--)mian();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3736kb
input:
2 6 7 1 2 1 3 2 3 3 4 4 5 4 6 5 6 3 2 1 2 2 3
output:
2 4 6 2
result:
ok ok (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1119ms
memory: 7388kb
input:
10000 2 1 1 2 29 28 13 19 16 5 21 7 22 10 10 2 1 18 27 13 10 3 11 23 12 22 11 7 7 17 29 17 9 1 28 21 2 18 13 9 4 25 20 16 5 14 20 7 14 4 12 8 8 24 17 19 15 1 11 6 26 9 13 12 13 9 12 2 6 12 9 11 5 2 8 10 6 10 3 10 7 1 7 5 8 9 4 1 12 11 10 6 2 8 12 4 5 10 11 1 3 1 10 1 12 9 9 1 8 3 7 1 35 35 13 8 34 1...
output:
2 23 4 29 8 10 1 6 7 19 12 13 5 26 28 2 4 6 8 7 12 2 4 6 8 1 7 2 4 34 8 25 9 13 30 17 20 22 16 26 21 33 28 11 2 4 6 8 10 12 14 16 18 2 2 4 2 12 6 34 17 33 23 1 5 35 22 31 9 28 30 13 20 36 38 29 7 47 46 39 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 2 4 6 8 10 12 14 2 4 6 8 10 12 ...
result:
wrong answer vertex 3 is not covered (test case 3)