Submission #1021678

# Submission time Handle Problem Language Result Execution time Memory
1021678 2024-07-13T02:25:27 Z idiotcomputer Pipes (CEOI15_pipes) C++11
0 / 100
710 ms 63316 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz size 
 
const int mxN = 1e5;

int p[mxN][2];
int ssize[mxN][2];
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	int n,m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) for (int j = 0; j < 2; j++) {p[i][j] = i; ssize[i][j] = 1;}
 
	int a,b;
	int x,y;
	int cnt = 0;
	for (int i = 0; i < m; i++){
		cin >> a >> b;
		a -= 1;
		b -= 1;
		while (p[a][0] != p[p[a][0]][0]) p[a][0] = p[p[a][0]][0];
		while (p[b][0] != p[p[b][0]][0]) p[b][0] = p[p[b][0]][0];
		x = p[a][0];
		y = p[b][0];
		if (x != y){
			//adj[a].pb(b);
			//adj[b].pb(a);
			cnt++;
			if (ssize[x][0] < ssize[y][0]) swap(x,y);
			ssize[x][0] += ssize[y][0];
			p[y][0] = x;
			continue;
		}
		while (p[a][1] != p[p[a][1]][1]) p[a][1] = p[p[a][1]][1];
		while (p[b][1] != p[p[b][1]][1]) p[b][1] = p[p[b][1]][1];
		x = p[a][1];
		y = p[b][1];
		if (x == y) continue;
		if (ssize[x][1] < ssize[y][1]) swap(x,y);
		ssize[x][1] += ssize[y][1];
		p[y][1] = x;
		//adj[a].pb(b);
		//adj[b].pb(a);
		cnt++;
	}
	if (cnt > 2*n-2) while(true) continue;
	//for (int i = 0; i < n; i++) d[i] = -1;
	//for (int i = 0; i < n; i++) if (d[i] == -1) dfs(i,0,-1);
	return 0;	
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 5640 KB Output is correct
2 Incorrect 58 ms 5460 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 9512 KB Output is correct
2 Incorrect 111 ms 10836 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 165 ms 15188 KB Output is correct
2 Incorrect 136 ms 14676 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 19896 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 343 ms 30984 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 40832 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 538 ms 50880 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 710 ms 63316 KB Memory limit exceeded
2 Halted 0 ms 0 KB -