#include "game.h"
#include <bits/stdc++.h>
using namespace std;
struct Nodo
{
vector <int> ady;
bool special = false;
};
vector <Nodo> g;
vector <bool> vis;
bool acPos = 0;
int K;
void dfs(int node, int start)
{
//cout<<"call "<<node<<endl;
vis[node] = true;
for (auto i : g[node].ady)
{
//cout<<"check "<<i<<endl;
if (!vis[i])
{
//cout<<"check "<<i<<endl;
dfs(i, start);
}else
{
if (i == start)
{
acPos = true;
}
}
}
}
void init(int n, int k)
{
vis.resize(n);
g.resize(n);
K = k;
for (int i = 0; i < k; i++)
{
g[i].special = true;
if (i != k-1)
{
g[i].ady.push_back(i+1);
}
}
}
int add_teleporter(int u, int v)
{
fill(vis.begin(), vis.end(), false);
g[u].ady.push_back(v);
if (!acPos)
{
for (int i = 0; i < K; i++)
{
dfs(i, i);
}
}
return acPos;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
5 |
Halted |
0 ms |
0 KB |
- |