답안 #982156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982156 2024-05-14T01:27:43 Z c2zi6 게임 (APIO22_game) C++17
60 / 100
4000 ms 40644 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);

		recalcmnt(v);
		recalcmxf(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 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 19 ms 3692 KB Output is correct
31 Correct 4 ms 2648 KB Output is correct
32 Correct 18 ms 4268 KB Output is correct
33 Correct 18 ms 4124 KB Output is correct
34 Correct 884 ms 4952 KB Output is correct
35 Correct 330 ms 4628 KB Output is correct
36 Correct 36 ms 4088 KB Output is correct
37 Correct 28 ms 4724 KB Output is correct
38 Correct 27 ms 4080 KB Output is correct
39 Correct 32 ms 4088 KB Output is correct
40 Correct 818 ms 5188 KB Output is correct
41 Correct 145 ms 4432 KB Output is correct
42 Correct 97 ms 4148 KB Output is correct
43 Correct 40 ms 5372 KB Output is correct
44 Correct 646 ms 5636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 19 ms 3692 KB Output is correct
31 Correct 4 ms 2648 KB Output is correct
32 Correct 18 ms 4268 KB Output is correct
33 Correct 18 ms 4124 KB Output is correct
34 Correct 884 ms 4952 KB Output is correct
35 Correct 330 ms 4628 KB Output is correct
36 Correct 36 ms 4088 KB Output is correct
37 Correct 28 ms 4724 KB Output is correct
38 Correct 27 ms 4080 KB Output is correct
39 Correct 32 ms 4088 KB Output is correct
40 Correct 818 ms 5188 KB Output is correct
41 Correct 145 ms 4432 KB Output is correct
42 Correct 97 ms 4148 KB Output is correct
43 Correct 40 ms 5372 KB Output is correct
44 Correct 646 ms 5636 KB Output is correct
45 Correct 204 ms 28428 KB Output is correct
46 Correct 12 ms 17752 KB Output is correct
47 Correct 10 ms 17752 KB Output is correct
48 Correct 335 ms 40644 KB Output is correct
49 Correct 220 ms 36456 KB Output is correct
50 Execution timed out 4098 ms 40416 KB Time limit exceeded
51 Halted 0 ms 0 KB -