Submission #657579

# Submission time Handle Problem Language Result Execution time Memory
657579 2022-11-10T10:03:12 Z TimDee Inside information (BOI21_servers) C++17
2.5 / 100
803 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i=0; i<n; ++i)

bitset<120000> a[120002];

void solve() {

	int n,q; cin>>n>>q;
	forn(i,n) a[i].set(i);

	vector<set<int>> a(n);
	vector<int> last(n);
	forn(i,n) last[i]=i;
	forn(i,n) a[i].insert(i);

	forn(Q,n-1+q) {
		char c;
		cin>>c;
		if (c=='S') {

			int u,v; cin>>u>>v; --u,--v;
			if (u!=last[u]) a[u]=a[last[u]];
			if (v!=last[v]) a[v]=a[last[v]];
			if (a[u].size()<a[v].size()) swap(u,v);
			for (auto x:a[v]) a[u].insert(x);
			a[v]=a[u];
			//last[u]=last[v]=u;
			//for (auto x:a[u]) cout<<x<<' '; cout<<"  ";
			//for (auto x:a[v]) cout<<x<<' '; cout<<'\n';

		} else if (c=='Q') {

			int u,x; cin>>u>>x; --u, --x;
			u=last[u];
			cout << (a[u].count(x)?"yes\n":"no\n");

		} else {
			int x; cin>>x; --x;
			cout<<0<<'\n';
		}
	}

}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 852 KB Output is correct
2 Correct 37 ms 18296 KB Output is correct
3 Correct 165 ms 63840 KB Output is correct
4 Correct 35 ms 17976 KB Output is correct
5 Correct 35 ms 17812 KB Output is correct
6 Correct 801 ms 392972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 852 KB Output is correct
2 Correct 37 ms 18296 KB Output is correct
3 Correct 165 ms 63840 KB Output is correct
4 Correct 35 ms 17976 KB Output is correct
5 Correct 35 ms 17812 KB Output is correct
6 Correct 801 ms 392972 KB Output is correct
7 Incorrect 18 ms 852 KB Extra information in the output file
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 952 KB Output is correct
2 Runtime error 202 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 952 KB Output is correct
2 Runtime error 202 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 832 KB Output is correct
2 Correct 344 ms 515476 KB Output is correct
3 Correct 328 ms 515624 KB Output is correct
4 Runtime error 218 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 832 KB Output is correct
2 Correct 344 ms 515476 KB Output is correct
3 Correct 328 ms 515624 KB Output is correct
4 Runtime error 218 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 852 KB Output is correct
2 Runtime error 243 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 852 KB Output is correct
2 Runtime error 243 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 792 KB Output is correct
2 Correct 327 ms 515488 KB Output is correct
3 Correct 328 ms 515516 KB Output is correct
4 Runtime error 196 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 792 KB Output is correct
2 Correct 327 ms 515488 KB Output is correct
3 Correct 328 ms 515516 KB Output is correct
4 Runtime error 196 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 828 KB Output is correct
2 Correct 37 ms 18296 KB Output is correct
3 Correct 137 ms 63744 KB Output is correct
4 Correct 37 ms 17996 KB Output is correct
5 Correct 34 ms 17812 KB Output is correct
6 Correct 803 ms 392972 KB Output is correct
7 Correct 20 ms 980 KB Output is correct
8 Runtime error 203 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 828 KB Output is correct
2 Correct 37 ms 18296 KB Output is correct
3 Correct 137 ms 63744 KB Output is correct
4 Correct 37 ms 17996 KB Output is correct
5 Correct 34 ms 17812 KB Output is correct
6 Correct 803 ms 392972 KB Output is correct
7 Correct 20 ms 980 KB Output is correct
8 Runtime error 203 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -