QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630664#7181. Graph CutsChief_NingWA 0ms3664kbC++201.5kb2024-10-11 19:49:472024-10-11 19:49:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-11 19:49:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-10-11 19:49:47]
  • 提交

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;
}

详细

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