QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457007 | #7181. Graph Cuts | arashMLG | RE | 0ms | 3648kb | C++17 | 1.6kb | 2024-06-28 20:42:34 | 2024-06-28 20:42:35 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#define debugArr(...) 69
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N = 23;
const int sq = 450;
const ll inf = 1e18;
#define F first
#define S second
#define pb push_back
#define kill(x) cout<<x<<endl, exit(0);
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lc (v << 1)
#define rc ((v<<1) |1)
#define big(x) (d[x] > sq)
int n,m;
bitset<N> bt;
vector<bitset<N>> GP;
vector<int> G[N];
int id[N];
int d[N];
bool is[N];
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n>>m;
for(int i = 1; i<= m ;i ++) {
int v,u; cin>>v>>u;
d[v] ++,d[u]++;
G[v].pb(i); G[u].pb(i);
is[i] =true;
}
int I = 0;
for(int i = 1; i<= n ;i ++) {
if(big(i)) {
GP.pb(bitset<N>());
id[i] = I;
for(int u : G[i]) {
GP[I][u] = 1;
}
I++;
//debug(i,GP[I-1]);
}
}
int q; cin>>q;
while(q--) {
char c; cin>>c;
debug(bt);
if(c != '?') {
int v; cin>>v;
if(big(v)) {
bt = bt ^ GP[id[v]];
} else {
for(int u : G[v]) if(is[u]) bt[u] = 1 - bt[u];
}
} else {
if(bt.none()) {
cout<<0 << '\n';
} else {
int x =bt._Find_first();
for(int i = 0; i < I; i ++) GP[i][x] = 0;
bt[x] = 0;
is[x] = 0;
cout<<x << '\n';
}
}
}
return 0;
}
// Jumpsuit, Jumpsuit cover me!
// Jumpsuit, Jumpsuit cover me!
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
4 5 1 2 1 3 1 4 2 3 2 4 10 + 1 + 2 ? ? ? ? ? - 2 ? ?
output:
2 3 4 5 0 1 0
result:
ok q=10
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
0 0 0
output:
result:
ok q=0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
0 0 1 ?
output:
0
result:
ok q=1
Test #4:
score: -100
Runtime Error
input:
1000 2000 1 50 1 88 331 1 1 352 1 497 2 32 2 282 550 2 989 2 334 3 3 665 4 38 4 69 4 343 4 451 589 4 917 4 89 5 5 162 675 5 681 6 7 22 127 7 7 592 7 672 787 7 8 310 107 9 9 137 184 9 9 244 378 9 446 9 9 658 883 9 65 10 75 10 414 10 10 468 686 10 245 11 269 11 11 386 403 11 493 11 394 12 493 12 565 1...