# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
982155 |
2024-05-14T01:26:38 Z |
c2zi6 |
게임 (APIO22_game) |
C++17 |
|
4000 ms |
40684 KB |
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "game.h"
int n, k;
VVI gp;
VVI trans;
VI mnt;
VI mxf;
void init(int N, int K) {n = N, k = K;
trans = gp = VVI(n);
replr(i, 0, k-2) {
gp[i].pb(i+1);
trans[i+1].pb(i);
}
mnt = VI(n, 2e9);
mxf = VI(n, -2e9);
rep(u, k) mnt[u] = mxf[u] = u;
}
bool verj;
void recalcmnt(int u) {
if (mxf[u] > mnt[u]) verj = true;
if (mxf[u] == mnt[u] && u >= k) verj = true;
for (int v : trans[u]) if (mnt[u] < mnt[v]) {
mnt[v] = mnt[u];
recalcmnt(v);
}
}
void recalcmxf(int u) {
if (mxf[u] > mnt[u]) verj = true;
if (mxf[u] == mnt[u] && u >= k) verj = true;
for (int v : gp[u]) if (mxf[u] > mxf[v]) {
mxf[v] = mxf[u];
recalcmxf(v);
}
}
int add_teleporter(int u, int v) {
if (u == v && u < k) return true;
verj = false;
gp[u].pb(v);
trans[v].pb(u);
if (mnt[v] < mnt[u]) {
mnt[u] = mnt[v];
recalcmnt(u);
}
if (mxf[u] > mxf[v]) {
mxf[v] = mxf[u];
recalcmxf(v);
}
if (verj) return true;
return false;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
600 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
600 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
680 KB |
Output is correct |
26 |
Correct |
2 ms |
928 KB |
Output is correct |
27 |
Correct |
2 ms |
544 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
600 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
600 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
680 KB |
Output is correct |
26 |
Correct |
2 ms |
928 KB |
Output is correct |
27 |
Correct |
2 ms |
544 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
14 ms |
3416 KB |
Output is correct |
31 |
Correct |
4 ms |
2592 KB |
Output is correct |
32 |
Correct |
16 ms |
4584 KB |
Output is correct |
33 |
Correct |
12 ms |
3928 KB |
Output is correct |
34 |
Correct |
888 ms |
5208 KB |
Output is correct |
35 |
Correct |
322 ms |
4512 KB |
Output is correct |
36 |
Correct |
30 ms |
4588 KB |
Output is correct |
37 |
Correct |
24 ms |
4184 KB |
Output is correct |
38 |
Correct |
26 ms |
4060 KB |
Output is correct |
39 |
Correct |
24 ms |
4436 KB |
Output is correct |
40 |
Correct |
748 ms |
5520 KB |
Output is correct |
41 |
Correct |
146 ms |
4248 KB |
Output is correct |
42 |
Correct |
96 ms |
3928 KB |
Output is correct |
43 |
Correct |
36 ms |
5200 KB |
Output is correct |
44 |
Correct |
638 ms |
4920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
600 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
600 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
680 KB |
Output is correct |
26 |
Correct |
2 ms |
928 KB |
Output is correct |
27 |
Correct |
2 ms |
544 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
14 ms |
3416 KB |
Output is correct |
31 |
Correct |
4 ms |
2592 KB |
Output is correct |
32 |
Correct |
16 ms |
4584 KB |
Output is correct |
33 |
Correct |
12 ms |
3928 KB |
Output is correct |
34 |
Correct |
888 ms |
5208 KB |
Output is correct |
35 |
Correct |
322 ms |
4512 KB |
Output is correct |
36 |
Correct |
30 ms |
4588 KB |
Output is correct |
37 |
Correct |
24 ms |
4184 KB |
Output is correct |
38 |
Correct |
26 ms |
4060 KB |
Output is correct |
39 |
Correct |
24 ms |
4436 KB |
Output is correct |
40 |
Correct |
748 ms |
5520 KB |
Output is correct |
41 |
Correct |
146 ms |
4248 KB |
Output is correct |
42 |
Correct |
96 ms |
3928 KB |
Output is correct |
43 |
Correct |
36 ms |
5200 KB |
Output is correct |
44 |
Correct |
638 ms |
4920 KB |
Output is correct |
45 |
Correct |
180 ms |
28588 KB |
Output is correct |
46 |
Correct |
9 ms |
17240 KB |
Output is correct |
47 |
Correct |
9 ms |
17240 KB |
Output is correct |
48 |
Correct |
317 ms |
40396 KB |
Output is correct |
49 |
Correct |
207 ms |
36184 KB |
Output is correct |
50 |
Execution timed out |
4058 ms |
40684 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |