Submission #745160

# Submission time Handle Problem Language Result Execution time Memory
745160 2023-05-19T13:25:50 Z CyberCraze Game (APIO22_game) C++17
0 / 100
1 ms 208 KB
#include <iostream>
#include <vector>
#include <unordered_set>
#include <stack>

using namespace std;

vector<vector<int>> graph;
unordered_set<int> special_planets;
bool has_infinite_stamps;

void init(int n, int k) {
    graph.resize(n);
    special_planets.clear();
    has_infinite_stamps = false;

    for (int i = 0; i < k; i++) {
        special_planets.insert(i);
    }
}

int add_teleporter(int u, int v) {
    graph[u].push_back(v);

    stack<int> stack;
    unordered_set<int> visited;

    stack.push(u);

    while (!stack.empty()) {
        int planet = stack.top();
        stack.pop();

        if (special_planets.count(planet) > 0) {
            has_infinite_stamps = true;
            return 1;
        }

        visited.insert(planet);

        for (int neighbor : graph[planet]) {
            if (visited.count(neighbor) == 0) {
                stack.push(neighbor);
            }
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -