Submission #706549

# Submission time Handle Problem Language Result Execution time Memory
706549 2023-03-07T02:09:37 Z grossly_overconfident Game (APIO22_game) C++17
2 / 100
117 ms 262144 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adjchart;
int K, N;


bool cycledetector4000(int i, int oi, bool f, vector<bool>& q, vector<bool>& dpcache){
	if (!f && i == oi){
		return true;
	}
	if (q[i]){
		return dpcache[i];
	}
	bool pl = false;
	for (int j : adjchart[i]){
		pl |= cycledetector4000(j, oi, false, q, dpcache);
	}
	q[i] = true;
	return dpcache[i] = pl;
}

void init(int n, int k) {
	adjchart.resize(n + 10);
	K = k;
	N = n;
	for (int i = 0; i < k - 1; ++i){
		adjchart[i].push_back(i + 1);
	}
}

int add_teleporter(int u, int v) {
	adjchart[u].push_back(v);
	vector<bool> q(N + 10);
	vector<bool> dpcache(N + 10);
	bool pl = false;
    for (int i = K - 1; i >= 0; --i){
		pl |= cycledetector4000(i, i, true, q, dpcache);
	}
	if (pl){
		return 1;
	}
	return 0;
}


int balls() {
	int n, k, m;
	cin >> n >> k >> m;
	init(n, k);
	for (int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		cout << add_teleporter(a, b) << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Runtime error 117 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Runtime error 117 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Runtime error 117 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Runtime error 117 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -