#include "game.h"
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>
using namespace std;
const int INF = (int)1e9 + 7;
int rad;
int getbucket(int a)
{
return a / rad;
}
int n, k;
vector<vector<int>> g, ig;
vector<int> mn, mnbu;
vector<int> precis;
bool is;
void addedge(int from, int to)
{
g[from].push_back(to);
ig[to].push_back(from);
}
void init(int nn, int kk)
{
is = 0;
n = nn;
k = kk;
rad = sqrt(n) + 2;
g.clear();
g.resize(n);
ig.clear();
ig.resize(n);
mn.clear();
mn.resize(n, +INF);
mnbu.clear();
mnbu.resize(n, +INF);
precis.clear();
precis.resize(n, 0);
}
void upd(int a, int b)
{
if (is)
{
return;
}
if (b < k)
{
if (b < mn[a])
{
mn[a] = b;
if (a < k && mn[a] <= a)
{
is = 1;
return;
}
for (auto& b : ig[a])
{
upd(b, mn[a]);
}
}
return;
}
if (mn[b] < mn[a])
{
mn[a] = mn[b];
if (a < k && mn[a] <= a)
{
is = 1;
return;
}
for (auto& b : ig[a])
{
upd(b, mn[a]);
}
}
}
int add_teleporter(int from, int to)
{
addedge(from, to);
if (to < k)
{
upd(from, to);
}
else
{
upd(from, to);
}
if (is)
{
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
0 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
0 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
336 KB |
Output is correct |
29 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
0 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
336 KB |
Output is correct |
29 |
Correct |
2 ms |
336 KB |
Output is correct |
30 |
Correct |
17 ms |
3176 KB |
Output is correct |
31 |
Correct |
5 ms |
2456 KB |
Output is correct |
32 |
Correct |
18 ms |
4296 KB |
Output is correct |
33 |
Correct |
20 ms |
3912 KB |
Output is correct |
34 |
Correct |
523 ms |
4812 KB |
Output is correct |
35 |
Correct |
193 ms |
4300 KB |
Output is correct |
36 |
Correct |
27 ms |
3840 KB |
Output is correct |
37 |
Correct |
25 ms |
3812 KB |
Output is correct |
38 |
Correct |
21 ms |
3608 KB |
Output is correct |
39 |
Correct |
26 ms |
3660 KB |
Output is correct |
40 |
Correct |
438 ms |
5036 KB |
Output is correct |
41 |
Correct |
111 ms |
3964 KB |
Output is correct |
42 |
Correct |
66 ms |
3880 KB |
Output is correct |
43 |
Correct |
29 ms |
4872 KB |
Output is correct |
44 |
Correct |
456 ms |
4816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
0 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
336 KB |
Output is correct |
29 |
Correct |
2 ms |
336 KB |
Output is correct |
30 |
Correct |
17 ms |
3176 KB |
Output is correct |
31 |
Correct |
5 ms |
2456 KB |
Output is correct |
32 |
Correct |
18 ms |
4296 KB |
Output is correct |
33 |
Correct |
20 ms |
3912 KB |
Output is correct |
34 |
Correct |
523 ms |
4812 KB |
Output is correct |
35 |
Correct |
193 ms |
4300 KB |
Output is correct |
36 |
Correct |
27 ms |
3840 KB |
Output is correct |
37 |
Correct |
25 ms |
3812 KB |
Output is correct |
38 |
Correct |
21 ms |
3608 KB |
Output is correct |
39 |
Correct |
26 ms |
3660 KB |
Output is correct |
40 |
Correct |
438 ms |
5036 KB |
Output is correct |
41 |
Correct |
111 ms |
3964 KB |
Output is correct |
42 |
Correct |
66 ms |
3880 KB |
Output is correct |
43 |
Correct |
29 ms |
4872 KB |
Output is correct |
44 |
Correct |
456 ms |
4816 KB |
Output is correct |
45 |
Correct |
258 ms |
29288 KB |
Output is correct |
46 |
Correct |
14 ms |
18324 KB |
Output is correct |
47 |
Correct |
15 ms |
18200 KB |
Output is correct |
48 |
Correct |
324 ms |
41360 KB |
Output is correct |
49 |
Correct |
259 ms |
36680 KB |
Output is correct |
50 |
Execution timed out |
4070 ms |
32012 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |