Submission #985333

# Submission time Handle Problem Language Result Execution time Memory
985333 2024-05-17T15:46:27 Z ph0enlx Game (APIO22_game) C++17
2 / 100
6 ms 14424 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5+10;
vector<set<int>> g(N);
int ng, kg;

bool dfs(int v, vector<bool>& vis, vector<bool>& rec)
{
    vis[v] = true;
    rec[v] = true;

    for (int child : g[v])
    {
        if (!vis[child] && dfs(child, vis, rec) && child<kg) return true;
        else if (rec[child] && child<kg) return true;
    }

    rec[v] = false;
    return false;
}

void init(int n, int k)
{
    ng = n, kg = k;
    for(int i=0; i<k-1; i++)
    {
        g[i].insert(i+1);
    }
}

int add_teleporter(int u, int v)
{
    if(u==v && u<kg) return 1;
    g[u].insert(v);
    vector<bool> vis(ng), rec(ng);
    for(int i=0; i<kg; i++)
    {
        if(vis[i]) continue;
        if(dfs(i, vis, rec)) return 1;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 14424 KB Output is correct
2 Correct 3 ms 14424 KB Output is correct
3 Correct 4 ms 14420 KB Output is correct
4 Correct 4 ms 14424 KB Output is correct
5 Correct 4 ms 14424 KB Output is correct
6 Correct 4 ms 14424 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 14424 KB Output is correct
2 Correct 3 ms 14424 KB Output is correct
3 Correct 4 ms 14420 KB Output is correct
4 Correct 4 ms 14424 KB Output is correct
5 Correct 4 ms 14424 KB Output is correct
6 Correct 4 ms 14424 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
8 Incorrect 5 ms 14292 KB Wrong Answer[1]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 14424 KB Output is correct
2 Correct 3 ms 14424 KB Output is correct
3 Correct 4 ms 14420 KB Output is correct
4 Correct 4 ms 14424 KB Output is correct
5 Correct 4 ms 14424 KB Output is correct
6 Correct 4 ms 14424 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
8 Incorrect 5 ms 14292 KB Wrong Answer[1]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 14424 KB Output is correct
2 Correct 3 ms 14424 KB Output is correct
3 Correct 4 ms 14420 KB Output is correct
4 Correct 4 ms 14424 KB Output is correct
5 Correct 4 ms 14424 KB Output is correct
6 Correct 4 ms 14424 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
8 Incorrect 5 ms 14292 KB Wrong Answer[1]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 14424 KB Output is correct
2 Correct 3 ms 14424 KB Output is correct
3 Correct 4 ms 14420 KB Output is correct
4 Correct 4 ms 14424 KB Output is correct
5 Correct 4 ms 14424 KB Output is correct
6 Correct 4 ms 14424 KB Output is correct
7 Correct 6 ms 14424 KB Output is correct
8 Incorrect 5 ms 14292 KB Wrong Answer[1]
9 Halted 0 ms 0 KB -