# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
652953 |
2022-10-25T09:30:53 Z |
aryan12 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
7376 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> g[N];
int max_n, max_k;
int vis[N];
int cnt = 0;
void init(int n, int k)
{
max_n = n, max_k = k;
for(int i = 0; i <= k - 2; i++)
{
g[i].push_back(i + 1);
}
}
bool dfsCycle(int node)
{
vis[node] = 1;
cnt += (node <= max_k - 1);
for(int to: g[node])
{
if(vis[to] == 1)
{
if(cnt != 0) return true;
continue;
}
if(dfsCycle(to)) return true;
}
vis[node] = 2;
cnt -= (node <= max_k - 1);
return false;
}
int add_teleporter(int u, int v)
{
cnt = 0;
g[u].push_back(v);
for(int i = 0; i <= max_n; i++)
{
vis[i] = 0;
}
for(int i = 0; i <= max_n; i++)
{
if(vis[i] == 0)
{
if(dfsCycle(i))
{
return 1;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7376 KB |
Output is correct |
3 |
Execution timed out |
4048 ms |
7248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7376 KB |
Output is correct |
3 |
Execution timed out |
4048 ms |
7248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7376 KB |
Output is correct |
3 |
Execution timed out |
4048 ms |
7248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7376 KB |
Output is correct |
3 |
Execution timed out |
4048 ms |
7248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7376 KB |
Output is correct |
3 |
Execution timed out |
4048 ms |
7248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |