#include "game.h"
#include<bits/stdc++.h>
using namespace std;
const int nmax=3e5+42;
int mem_n,mem_k;
vector<int> adj[nmax];
void init(int n, int k)
{
mem_n=n;
mem_k=k;
for(int i=1;i<k;i++)
adj[i-1].push_back(i);
}
bool ok;
bool been[nmax];
int ROOT;
void dfs(int node)
{
if(ok)return;
if(node<ROOT)
{
ok=1;
return;
}
if(been[node])
{
ok=(node==ROOT);
return;
}
been[node]=1;
for(auto w:adj[node])
dfs(w);
}
int add_teleporter(int u, int v)
{
adj[u].push_back(v);
ok=0;
for(int i=0;i<mem_n;i++)
been[i]=0;
for(ROOT=mem_k-1;ROOT>=0;ROOT--)
dfs(ROOT);
return ok;
}
/*
namespace {
int read_int() {
int x;
if (scanf("%d", &x) != 1) {
fprintf(stderr, "Error while reading input\n");
exit(1);
}
return x;
}
} // namespace
int main() {
int N = read_int();
int M = read_int();
int K = read_int();
std::vector<int> u(M), v(M);
for (int i = 0; i < M; ++i) {
u[i] = read_int();
v[i] = read_int();
}
init(N, K);
int i;
for (i = 0; i < M; ++i) {
int answer = add_teleporter(u[i], v[i]);
if (answer != 0 && answer != 1) {
i = -1;
break;
} else if (answer == 1) {
break;
}
}
printf("%d\n", i);
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
4 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7376 KB |
Output is correct |
7 |
Correct |
4 ms |
7248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
4 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7376 KB |
Output is correct |
7 |
Correct |
4 ms |
7248 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
4 ms |
7248 KB |
Output is correct |
12 |
Correct |
4 ms |
7248 KB |
Output is correct |
13 |
Correct |
5 ms |
7268 KB |
Output is correct |
14 |
Correct |
4 ms |
7248 KB |
Output is correct |
15 |
Correct |
3 ms |
7248 KB |
Output is correct |
16 |
Correct |
4 ms |
7248 KB |
Output is correct |
17 |
Correct |
4 ms |
7248 KB |
Output is correct |
18 |
Correct |
4 ms |
7352 KB |
Output is correct |
19 |
Correct |
4 ms |
7248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
4 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7376 KB |
Output is correct |
7 |
Correct |
4 ms |
7248 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
4 ms |
7248 KB |
Output is correct |
12 |
Correct |
4 ms |
7248 KB |
Output is correct |
13 |
Correct |
5 ms |
7268 KB |
Output is correct |
14 |
Correct |
4 ms |
7248 KB |
Output is correct |
15 |
Correct |
3 ms |
7248 KB |
Output is correct |
16 |
Correct |
4 ms |
7248 KB |
Output is correct |
17 |
Correct |
4 ms |
7248 KB |
Output is correct |
18 |
Correct |
4 ms |
7352 KB |
Output is correct |
19 |
Correct |
4 ms |
7248 KB |
Output is correct |
20 |
Correct |
4 ms |
7248 KB |
Output is correct |
21 |
Correct |
5 ms |
7356 KB |
Output is correct |
22 |
Correct |
5 ms |
7360 KB |
Output is correct |
23 |
Correct |
4 ms |
7360 KB |
Output is correct |
24 |
Correct |
10 ms |
7376 KB |
Output is correct |
25 |
Correct |
39 ms |
7384 KB |
Output is correct |
26 |
Correct |
59 ms |
7508 KB |
Output is correct |
27 |
Correct |
61 ms |
7388 KB |
Output is correct |
28 |
Correct |
18 ms |
7376 KB |
Output is correct |
29 |
Correct |
43 ms |
7376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
4 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7376 KB |
Output is correct |
7 |
Correct |
4 ms |
7248 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
4 ms |
7248 KB |
Output is correct |
12 |
Correct |
4 ms |
7248 KB |
Output is correct |
13 |
Correct |
5 ms |
7268 KB |
Output is correct |
14 |
Correct |
4 ms |
7248 KB |
Output is correct |
15 |
Correct |
3 ms |
7248 KB |
Output is correct |
16 |
Correct |
4 ms |
7248 KB |
Output is correct |
17 |
Correct |
4 ms |
7248 KB |
Output is correct |
18 |
Correct |
4 ms |
7352 KB |
Output is correct |
19 |
Correct |
4 ms |
7248 KB |
Output is correct |
20 |
Correct |
4 ms |
7248 KB |
Output is correct |
21 |
Correct |
5 ms |
7356 KB |
Output is correct |
22 |
Correct |
5 ms |
7360 KB |
Output is correct |
23 |
Correct |
4 ms |
7360 KB |
Output is correct |
24 |
Correct |
10 ms |
7376 KB |
Output is correct |
25 |
Correct |
39 ms |
7384 KB |
Output is correct |
26 |
Correct |
59 ms |
7508 KB |
Output is correct |
27 |
Correct |
61 ms |
7388 KB |
Output is correct |
28 |
Correct |
18 ms |
7376 KB |
Output is correct |
29 |
Correct |
43 ms |
7376 KB |
Output is correct |
30 |
Correct |
141 ms |
7848 KB |
Output is correct |
31 |
Correct |
67 ms |
7580 KB |
Output is correct |
32 |
Correct |
70 ms |
8720 KB |
Output is correct |
33 |
Correct |
46 ms |
8232 KB |
Output is correct |
34 |
Correct |
1072 ms |
9200 KB |
Output is correct |
35 |
Execution timed out |
4083 ms |
8300 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
4 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7376 KB |
Output is correct |
7 |
Correct |
4 ms |
7248 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
4 ms |
7248 KB |
Output is correct |
12 |
Correct |
4 ms |
7248 KB |
Output is correct |
13 |
Correct |
5 ms |
7268 KB |
Output is correct |
14 |
Correct |
4 ms |
7248 KB |
Output is correct |
15 |
Correct |
3 ms |
7248 KB |
Output is correct |
16 |
Correct |
4 ms |
7248 KB |
Output is correct |
17 |
Correct |
4 ms |
7248 KB |
Output is correct |
18 |
Correct |
4 ms |
7352 KB |
Output is correct |
19 |
Correct |
4 ms |
7248 KB |
Output is correct |
20 |
Correct |
4 ms |
7248 KB |
Output is correct |
21 |
Correct |
5 ms |
7356 KB |
Output is correct |
22 |
Correct |
5 ms |
7360 KB |
Output is correct |
23 |
Correct |
4 ms |
7360 KB |
Output is correct |
24 |
Correct |
10 ms |
7376 KB |
Output is correct |
25 |
Correct |
39 ms |
7384 KB |
Output is correct |
26 |
Correct |
59 ms |
7508 KB |
Output is correct |
27 |
Correct |
61 ms |
7388 KB |
Output is correct |
28 |
Correct |
18 ms |
7376 KB |
Output is correct |
29 |
Correct |
43 ms |
7376 KB |
Output is correct |
30 |
Correct |
141 ms |
7848 KB |
Output is correct |
31 |
Correct |
67 ms |
7580 KB |
Output is correct |
32 |
Correct |
70 ms |
8720 KB |
Output is correct |
33 |
Correct |
46 ms |
8232 KB |
Output is correct |
34 |
Correct |
1072 ms |
9200 KB |
Output is correct |
35 |
Execution timed out |
4083 ms |
8300 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |