# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
773504 |
2023-07-05T06:15:00 Z |
LittleCube |
Game (APIO22_game) |
C++17 |
|
257 ms |
262144 KB |
#pragma GCC optimize("Ofast,unroll-loops")
#include "game.h"
#ifndef EVAL
#include "game_grader.cpp"
#endif
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
namespace
{
int n, k, from[300000][17], to[300000][17], where[300000][17];
vector<int> Ef[300000][17], Et[300000][17];
void update_from(int u, int layer, vector<int> &same)
{
if (from[u][layer] == to[u][layer])
same.emplace_back(u);
for (auto v : Ef[u][layer])
if (from[u][layer] > from[v][layer])
{
from[v][layer] = from[u][layer];
update_from(v, layer, same);
}
}
void update_to(int u, int layer, vector<int> &same)
{
if (from[u][layer] == to[u][layer])
same.emplace_back(u);
for (auto v : Et[u][layer])
if (to[u][layer] < to[v][layer])
{
to[v][layer] = to[u][layer];
update_to(v, layer, same);
}
}
void build(int i = 1, int L = 0, int R = k - 1, int l = 0)
{
for (int j = L; j <= R; j++)
where[j][l] = i;
if (L != R)
{
int mid = (L + R) / 2;
for (int j = L; j <= mid; j++)
from[j][l] = to[j][l] = 1;
for (int j = mid + 1; j <= R; j++)
from[j][l] = to[j][l] = 2;
build(i << 1, L, mid, l + 1);
build(i << 1 | 1, mid + 1, R, l + 1);
}
else
from[L][l] = 2, to[L][l] = 1;
}
int add_edge(int, int, int, int);
int add_node(int u, int i, int l)
{
if (where[u][l])
return 0;
where[u][l] = i;
from[u][l] = 0, to[u][l] = 3;
bool flag = 0;
for (auto v : Et[u][l - 1])
if (where[u][l] == where[v][l])
flag |= add_edge(v, u, i, l);
for (auto v : Ef[u][l - 1])
if (where[u][l] == where[v][l])
flag |= add_edge(u, v, i, l);
return flag | (from[u][l] > to[u][l]);
}
int add_edge(int u, int v, int i = 1, int l = 0)
{
Ef[u][l].emplace_back(v);
Et[v][l].emplace_back(u);
from[v][l] = max(from[v][l], from[u][l]);
to[u][l] = min(to[u][l], to[v][l]);
vector<int> s;
bool flag = 0;
if (v >= k)
{
update_from(v, l, s);
flag |= (from[v][l] > to[v][l]);
}
if (u >= k)
{
update_to(u, l, s);
flag |= (from[u][l] > to[u][l]);
}
if(where[u][l + 1] == where[v][l + 1] && where[u][l + 1] > 0)
flag |= add_edge(u, v, where[u][l + 1], l + 1);
for (int w : s)
if (from[w][l] == 1)
flag |= add_node(w, i << 1, l + 1);
else
flag |= add_node(w, i << 1 | 1, l + 1);
return flag;
}
}
void init(int n, int k)
{
::n = n, ::k = k;
build();
for (int i = k; i < n; i++)
{
from[i][0] = 0, to[i][0] = 3;
where[i][0] = 1;
}
}
int add_teleporter(int u, int v)
{
if (u < k && v < k)
{
if (v <= u)
return 1;
return 0;
}
bool ans = add_edge(u, v);
// cout << u << ' ' << v << '\n';
// for (int p = 0; p < 5; p++)
// for (int i = 0; i < n; i++)
// cout << from[i][p] << ' ' << to[i][p] << ' ' << " \n"[i == n - 1];
// for (int p = 0; p < 5; p++)
// for (int i = 0; i < n; i++)
// cout << where[i][p] << " \n"[i == n - 1];
// cout << '\n';
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
239836 KB |
Output is correct |
2 |
Correct |
119 ms |
239712 KB |
Output is correct |
3 |
Correct |
114 ms |
239760 KB |
Output is correct |
4 |
Correct |
122 ms |
239824 KB |
Output is correct |
5 |
Correct |
117 ms |
239840 KB |
Output is correct |
6 |
Correct |
118 ms |
239728 KB |
Output is correct |
7 |
Correct |
118 ms |
239792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
239836 KB |
Output is correct |
2 |
Correct |
119 ms |
239712 KB |
Output is correct |
3 |
Correct |
114 ms |
239760 KB |
Output is correct |
4 |
Correct |
122 ms |
239824 KB |
Output is correct |
5 |
Correct |
117 ms |
239840 KB |
Output is correct |
6 |
Correct |
118 ms |
239728 KB |
Output is correct |
7 |
Correct |
118 ms |
239792 KB |
Output is correct |
8 |
Correct |
115 ms |
239728 KB |
Output is correct |
9 |
Correct |
119 ms |
239712 KB |
Output is correct |
10 |
Correct |
118 ms |
239784 KB |
Output is correct |
11 |
Correct |
120 ms |
239844 KB |
Output is correct |
12 |
Correct |
116 ms |
239860 KB |
Output is correct |
13 |
Correct |
127 ms |
239820 KB |
Output is correct |
14 |
Correct |
121 ms |
239872 KB |
Output is correct |
15 |
Correct |
120 ms |
239848 KB |
Output is correct |
16 |
Correct |
124 ms |
239760 KB |
Output is correct |
17 |
Correct |
117 ms |
239848 KB |
Output is correct |
18 |
Correct |
121 ms |
239848 KB |
Output is correct |
19 |
Correct |
124 ms |
239800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
239836 KB |
Output is correct |
2 |
Correct |
119 ms |
239712 KB |
Output is correct |
3 |
Correct |
114 ms |
239760 KB |
Output is correct |
4 |
Correct |
122 ms |
239824 KB |
Output is correct |
5 |
Correct |
117 ms |
239840 KB |
Output is correct |
6 |
Correct |
118 ms |
239728 KB |
Output is correct |
7 |
Correct |
118 ms |
239792 KB |
Output is correct |
8 |
Correct |
115 ms |
239728 KB |
Output is correct |
9 |
Correct |
119 ms |
239712 KB |
Output is correct |
10 |
Correct |
118 ms |
239784 KB |
Output is correct |
11 |
Correct |
120 ms |
239844 KB |
Output is correct |
12 |
Correct |
116 ms |
239860 KB |
Output is correct |
13 |
Correct |
127 ms |
239820 KB |
Output is correct |
14 |
Correct |
121 ms |
239872 KB |
Output is correct |
15 |
Correct |
120 ms |
239848 KB |
Output is correct |
16 |
Correct |
124 ms |
239760 KB |
Output is correct |
17 |
Correct |
117 ms |
239848 KB |
Output is correct |
18 |
Correct |
121 ms |
239848 KB |
Output is correct |
19 |
Correct |
124 ms |
239800 KB |
Output is correct |
20 |
Correct |
116 ms |
240040 KB |
Output is correct |
21 |
Correct |
119 ms |
240040 KB |
Output is correct |
22 |
Correct |
118 ms |
240052 KB |
Output is correct |
23 |
Correct |
126 ms |
240000 KB |
Output is correct |
24 |
Correct |
120 ms |
240372 KB |
Output is correct |
25 |
Correct |
119 ms |
240200 KB |
Output is correct |
26 |
Correct |
122 ms |
240348 KB |
Output is correct |
27 |
Correct |
127 ms |
240440 KB |
Output is correct |
28 |
Correct |
127 ms |
240200 KB |
Output is correct |
29 |
Correct |
118 ms |
240324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
239836 KB |
Output is correct |
2 |
Correct |
119 ms |
239712 KB |
Output is correct |
3 |
Correct |
114 ms |
239760 KB |
Output is correct |
4 |
Correct |
122 ms |
239824 KB |
Output is correct |
5 |
Correct |
117 ms |
239840 KB |
Output is correct |
6 |
Correct |
118 ms |
239728 KB |
Output is correct |
7 |
Correct |
118 ms |
239792 KB |
Output is correct |
8 |
Correct |
115 ms |
239728 KB |
Output is correct |
9 |
Correct |
119 ms |
239712 KB |
Output is correct |
10 |
Correct |
118 ms |
239784 KB |
Output is correct |
11 |
Correct |
120 ms |
239844 KB |
Output is correct |
12 |
Correct |
116 ms |
239860 KB |
Output is correct |
13 |
Correct |
127 ms |
239820 KB |
Output is correct |
14 |
Correct |
121 ms |
239872 KB |
Output is correct |
15 |
Correct |
120 ms |
239848 KB |
Output is correct |
16 |
Correct |
124 ms |
239760 KB |
Output is correct |
17 |
Correct |
117 ms |
239848 KB |
Output is correct |
18 |
Correct |
121 ms |
239848 KB |
Output is correct |
19 |
Correct |
124 ms |
239800 KB |
Output is correct |
20 |
Correct |
116 ms |
240040 KB |
Output is correct |
21 |
Correct |
119 ms |
240040 KB |
Output is correct |
22 |
Correct |
118 ms |
240052 KB |
Output is correct |
23 |
Correct |
126 ms |
240000 KB |
Output is correct |
24 |
Correct |
120 ms |
240372 KB |
Output is correct |
25 |
Correct |
119 ms |
240200 KB |
Output is correct |
26 |
Correct |
122 ms |
240348 KB |
Output is correct |
27 |
Correct |
127 ms |
240440 KB |
Output is correct |
28 |
Correct |
127 ms |
240200 KB |
Output is correct |
29 |
Correct |
118 ms |
240324 KB |
Output is correct |
30 |
Correct |
141 ms |
246892 KB |
Output is correct |
31 |
Correct |
133 ms |
246300 KB |
Output is correct |
32 |
Correct |
177 ms |
251168 KB |
Output is correct |
33 |
Correct |
156 ms |
247708 KB |
Output is correct |
34 |
Runtime error |
257 ms |
262144 KB |
Execution killed with signal 9 |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
239836 KB |
Output is correct |
2 |
Correct |
119 ms |
239712 KB |
Output is correct |
3 |
Correct |
114 ms |
239760 KB |
Output is correct |
4 |
Correct |
122 ms |
239824 KB |
Output is correct |
5 |
Correct |
117 ms |
239840 KB |
Output is correct |
6 |
Correct |
118 ms |
239728 KB |
Output is correct |
7 |
Correct |
118 ms |
239792 KB |
Output is correct |
8 |
Correct |
115 ms |
239728 KB |
Output is correct |
9 |
Correct |
119 ms |
239712 KB |
Output is correct |
10 |
Correct |
118 ms |
239784 KB |
Output is correct |
11 |
Correct |
120 ms |
239844 KB |
Output is correct |
12 |
Correct |
116 ms |
239860 KB |
Output is correct |
13 |
Correct |
127 ms |
239820 KB |
Output is correct |
14 |
Correct |
121 ms |
239872 KB |
Output is correct |
15 |
Correct |
120 ms |
239848 KB |
Output is correct |
16 |
Correct |
124 ms |
239760 KB |
Output is correct |
17 |
Correct |
117 ms |
239848 KB |
Output is correct |
18 |
Correct |
121 ms |
239848 KB |
Output is correct |
19 |
Correct |
124 ms |
239800 KB |
Output is correct |
20 |
Correct |
116 ms |
240040 KB |
Output is correct |
21 |
Correct |
119 ms |
240040 KB |
Output is correct |
22 |
Correct |
118 ms |
240052 KB |
Output is correct |
23 |
Correct |
126 ms |
240000 KB |
Output is correct |
24 |
Correct |
120 ms |
240372 KB |
Output is correct |
25 |
Correct |
119 ms |
240200 KB |
Output is correct |
26 |
Correct |
122 ms |
240348 KB |
Output is correct |
27 |
Correct |
127 ms |
240440 KB |
Output is correct |
28 |
Correct |
127 ms |
240200 KB |
Output is correct |
29 |
Correct |
118 ms |
240324 KB |
Output is correct |
30 |
Correct |
141 ms |
246892 KB |
Output is correct |
31 |
Correct |
133 ms |
246300 KB |
Output is correct |
32 |
Correct |
177 ms |
251168 KB |
Output is correct |
33 |
Correct |
156 ms |
247708 KB |
Output is correct |
34 |
Runtime error |
257 ms |
262144 KB |
Execution killed with signal 9 |
35 |
Halted |
0 ms |
0 KB |
- |