QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630664 | #7181. Graph Cuts | Chief_Ning | WA | 0ms | 3664kb | C++20 | 1.5kb | 2024-10-11 19:49:47 | 2024-10-11 19:49:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using u64 = unsigned long long;
using u32 = unsigned int;
using i64 = long long;
mt19937_64 rnd(random_device{}());
const int mod = 998244353;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
int n, m, s, t;
int q;
void RuinGuard(int tc)
{
cin >> n >> m;
bitset<N> edge;
edge.set();
const int limit = 350;
vector e(n + 1, vector<int>(0));
for(int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
e[u].push_back(v);
e[v].push_back(u);
}
int cnt = 0;
for(int i = 1; i <= n; i++) {
if(e[i].size() > limit) {
cnt += 1;
}
}
vector<bitset<N>> link(cnt + 1);
for(int i = 1; i <= n; i++) {
if(e[i].size() > limit) {
for(auto adj : e[i]) {
link[i][adj] = 1;
}
}
}
bitset<N> mask;
cin >> q;
for(int i = 1; i <= q; i++) {
char op;
int x;
cin >> op;
if(op == '+' || op == '-') {
cin >> x;
if(e[x].size() > limit) {
mask ^= link[x];
} else {
for(auto adj : e[x]) {
mask.flip(adj);
}
}
} else {
auto res = edge & mask;
if(res.any()) {
int adj = res._Find_first();
cout << adj << '\n';
edge[adj] = 0;
} else {
cout << 0 << '\n';
}
}
}
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int testcase = 1;
//cin >> testcase;
for(int tc = 1; tc <= testcase; tc++) {
RuinGuard(tc);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3664kb
input:
4 5 1 2 1 3 1 4 2 3 2 4 10 + 1 + 2 ? ? ? ? ? - 2 ? ?
output:
1 2 0 0 0 3 4
result:
wrong answer Chosen edge is not in the cut