QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#123179 | #6413. Classical Graph Theory Problem | c20230537 | RE | 68ms | 3920kb | C++14 | 1.1kb | 2023-07-11 20:36:58 | 2023-07-11 20:37:01 |
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");
For(i,1,n)e[i].clear(),t[i][0]=t[i][1]=0;
}
int main(){
int T=1;
scanf("%d",&T);
while(T--)mian();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3920kb
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: 0
Accepted
time: 68ms
memory: 3708kb
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 2 4 6 27 17 24 15 16 10 19 22 21 9 23 2 4 9 10 7 6 3 7 11 10 2 12 2 4 6 5 30 28 21 13 18 25 22 24 20 9 27 32 12 2 4 13 8 7 5 3 9 14 2 2 4 2 27 6 11 49 39 17 16 18 20 22 24 14 5 23 32 34 47 38 13 42 37 46 9 29 35 4 6 8 11 25 14 22 18 20 2 24 27 28 12 32 34 36 2 4 14 8 9 7 1 3 2 6 15 10 9...
result:
ok ok (10000 test cases)
Test #3:
score: -100
Runtime Error
input:
1000 337 338 164 11 138 75 114 262 170 298 166 241 269 24 9 134 233 60 50 222 231 253 296 242 173 18 93 223 116 151 312 150 82 236 180 20 297 184 268 70 334 162 217 135 258 321 80 209 212 208 18 163 227 104 334 135 77 118 17 230 307 105 307 335 29 24 111 177 324 24 85 3 214 191 310 182 22 171 202 21...
output:
15 319 46 8 305 292 168 16 64 143 160 24 186 28 30 59 34 36 196 336 269 44 180 181 169 52 215 323 58 235 167 148 316 256 49 245 53 173 308 80 313 84 86 88 90 85 118 96 98 142 102 104 243 108 110 208 25 116 101 250 20 189 126 310 130 83 134 136 155 275 335 144 146 251 124 10 154 156 158 214 176 253 1...