Submission #731061

# Submission time Handle Problem Language Result Execution time Memory
731061 2023-04-26T21:24:33 Z grossly_overconfident Game (APIO22_game) C++17
2 / 100
1 ms 256 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> la, sd;
int n, k;
int par(vector<int>& p, int i){
	if (i == p[i]){
		return i;
	}
	return par(p, p[i]);
}

int solvesmaller(int a, int b){
	if (a >= k && b >= k){
		return a;
	}
	if (b >= k){
		return a;
	}
	if (a >= k){
		return b;
	}
	return min(a, b);
}

int solvelarger(int a, int b){
	if (a >= k && b >= k){
		return b;
	}
	if (b >= k){
		return a;
	}
	if (a >= k){
		return b;
	}
	return max(a, b);
}

void init(int N, int K) {
	n = N;
	k = K;
	la.resize(n);
	sd.resize(n);
	iota(la.begin(), la.end(), 0);
	iota(sd.begin(), sd.end(), 0);
	
}

int add_teleporter(int u, int v) {
	if (u < k && v < k){
		if (u >= v){
			return 1;
		}
	}
	sd[par(sd, u)] = solvesmaller(par(sd, v), par(sd, u));
	la[par(la, v)] = solvelarger(par(la, v), par(la, u));
	/*
	for (int i : sd){
		cout << i << " ";
	}
	cout << endl;
	for (int i : la){
		cout << i << " ";
	}
	cout << endl;
	*/
	if (par(sd, u) <= par(la, u) && par(sd, u) < k && par(la, u) < k && u >= k){
		return 1;
	}
	if (par(sd, v) <= par(la, v) && par(sd, v) < k && par(la, v) < k && v >= k){
		return 1;
	}
	return 0;
}

int nothing() {
	int n, k;
	cin >> n >> k;
	init(n, k);
	int m = 0;
	while (m != 1){
		int a, b;
		cin >> a >> b;
		m = add_teleporter(a, b);
		cout << m << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 1 ms 208 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 1 ms 208 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 1 ms 208 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 1 ms 208 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -