답안 #919124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919124 2024-01-31T10:37:38 Z Mher777 게임 (APIO22_game) C++17
60 / 100
4000 ms 47248 KB
#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
using namespace std;

/* -------------------- Typedefs -------------------- */

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef float fl;
typedef double db;
typedef long double ld;

/* -------------------- Usings -------------------- */

using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* -------------------- Defines -------------------- */

#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define all(x) (x).begin(), (x).end()

/* -------------------- Constants -------------------- */

const int MAX = int(2e9 + 5);
const ll MAXL = ll(1e18 + 5);
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);

//dp1->maximum gagaty voric karas gas, dp2->minimum gagaty vor hasanelia tvyal gagatic
const int max_N = 300005;
int n, k;
vi g[max_N], g_rev[max_N];
int dp1[max_N], dp2[max_N], used[max_N];
vi nodes;

void dfs1(int u) {
	nodes.pub(u);
	used[u] = 1;
	for (auto to : g[u]) {
		if (!used[to] && dp1[to] < dp1[u]) {
			dp1[to] = dp1[u];
			dfs1(to);
		}
	}
}

void dfs2(int u) {
	nodes.pub(u);
	used[u] = 1;
	for (auto to : g_rev[u]) {
		if (!used[to] && dp2[to] > dp2[u]) {
			dp2[to] = dp2[u];
			dfs2(to);
		}
	}
}

void init(int N, int K) {
	n = N, k = K;
	for (int i = 0; i < k - 1; ++i) {
		g[i].pub(i + 1);
		dp1[i] = dp2[i] = i;
		g_rev[i + 1].pub(i);
	}
	dp1[k - 1] = dp2[k - 1] = k - 1;
	for (int i = k; i < n; ++i) {
		dp1[i] = -1;
		dp2[i] = MAX;
	}
}

int add_teleporter(int u, int v) {
	if (dp1[u] >= dp2[v]) return 1;
	g[u].pub(v);
	g_rev[v].pub(u);
	nodes.clear();
	dfs1(u);
	for (auto node : nodes) used[node] = 0;
	nodes.clear();
	dfs2(v);
	for (auto node : nodes) used[node] = 0;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17752 KB Output is correct
2 Correct 5 ms 17752 KB Output is correct
3 Correct 5 ms 17752 KB Output is correct
4 Correct 6 ms 17752 KB Output is correct
5 Correct 5 ms 17752 KB Output is correct
6 Correct 4 ms 17752 KB Output is correct
7 Correct 5 ms 17752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17752 KB Output is correct
2 Correct 5 ms 17752 KB Output is correct
3 Correct 5 ms 17752 KB Output is correct
4 Correct 6 ms 17752 KB Output is correct
5 Correct 5 ms 17752 KB Output is correct
6 Correct 4 ms 17752 KB Output is correct
7 Correct 5 ms 17752 KB Output is correct
8 Correct 5 ms 17912 KB Output is correct
9 Correct 6 ms 17752 KB Output is correct
10 Correct 5 ms 17752 KB Output is correct
11 Correct 5 ms 17752 KB Output is correct
12 Correct 5 ms 17752 KB Output is correct
13 Correct 5 ms 17752 KB Output is correct
14 Correct 5 ms 17752 KB Output is correct
15 Correct 5 ms 17752 KB Output is correct
16 Correct 5 ms 17752 KB Output is correct
17 Correct 5 ms 17752 KB Output is correct
18 Correct 5 ms 17752 KB Output is correct
19 Correct 5 ms 17752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17752 KB Output is correct
2 Correct 5 ms 17752 KB Output is correct
3 Correct 5 ms 17752 KB Output is correct
4 Correct 6 ms 17752 KB Output is correct
5 Correct 5 ms 17752 KB Output is correct
6 Correct 4 ms 17752 KB Output is correct
7 Correct 5 ms 17752 KB Output is correct
8 Correct 5 ms 17912 KB Output is correct
9 Correct 6 ms 17752 KB Output is correct
10 Correct 5 ms 17752 KB Output is correct
11 Correct 5 ms 17752 KB Output is correct
12 Correct 5 ms 17752 KB Output is correct
13 Correct 5 ms 17752 KB Output is correct
14 Correct 5 ms 17752 KB Output is correct
15 Correct 5 ms 17752 KB Output is correct
16 Correct 5 ms 17752 KB Output is correct
17 Correct 5 ms 17752 KB Output is correct
18 Correct 5 ms 17752 KB Output is correct
19 Correct 5 ms 17752 KB Output is correct
20 Correct 5 ms 17752 KB Output is correct
21 Correct 5 ms 17752 KB Output is correct
22 Correct 5 ms 17752 KB Output is correct
23 Correct 5 ms 17752 KB Output is correct
24 Correct 8 ms 17752 KB Output is correct
25 Correct 6 ms 17752 KB Output is correct
26 Correct 6 ms 17752 KB Output is correct
27 Correct 6 ms 17752 KB Output is correct
28 Correct 6 ms 17752 KB Output is correct
29 Correct 6 ms 17752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17752 KB Output is correct
2 Correct 5 ms 17752 KB Output is correct
3 Correct 5 ms 17752 KB Output is correct
4 Correct 6 ms 17752 KB Output is correct
5 Correct 5 ms 17752 KB Output is correct
6 Correct 4 ms 17752 KB Output is correct
7 Correct 5 ms 17752 KB Output is correct
8 Correct 5 ms 17912 KB Output is correct
9 Correct 6 ms 17752 KB Output is correct
10 Correct 5 ms 17752 KB Output is correct
11 Correct 5 ms 17752 KB Output is correct
12 Correct 5 ms 17752 KB Output is correct
13 Correct 5 ms 17752 KB Output is correct
14 Correct 5 ms 17752 KB Output is correct
15 Correct 5 ms 17752 KB Output is correct
16 Correct 5 ms 17752 KB Output is correct
17 Correct 5 ms 17752 KB Output is correct
18 Correct 5 ms 17752 KB Output is correct
19 Correct 5 ms 17752 KB Output is correct
20 Correct 5 ms 17752 KB Output is correct
21 Correct 5 ms 17752 KB Output is correct
22 Correct 5 ms 17752 KB Output is correct
23 Correct 5 ms 17752 KB Output is correct
24 Correct 8 ms 17752 KB Output is correct
25 Correct 6 ms 17752 KB Output is correct
26 Correct 6 ms 17752 KB Output is correct
27 Correct 6 ms 17752 KB Output is correct
28 Correct 6 ms 17752 KB Output is correct
29 Correct 6 ms 17752 KB Output is correct
30 Correct 16 ms 19396 KB Output is correct
31 Correct 8 ms 18712 KB Output is correct
32 Correct 25 ms 20260 KB Output is correct
33 Correct 21 ms 20340 KB Output is correct
34 Correct 1002 ms 21924 KB Output is correct
35 Correct 337 ms 20852 KB Output is correct
36 Correct 41 ms 20408 KB Output is correct
37 Correct 28 ms 20312 KB Output is correct
38 Correct 33 ms 19980 KB Output is correct
39 Correct 35 ms 20196 KB Output is correct
40 Correct 807 ms 22248 KB Output is correct
41 Correct 146 ms 20332 KB Output is correct
42 Correct 108 ms 20156 KB Output is correct
43 Correct 38 ms 21584 KB Output is correct
44 Correct 700 ms 22232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17752 KB Output is correct
2 Correct 5 ms 17752 KB Output is correct
3 Correct 5 ms 17752 KB Output is correct
4 Correct 6 ms 17752 KB Output is correct
5 Correct 5 ms 17752 KB Output is correct
6 Correct 4 ms 17752 KB Output is correct
7 Correct 5 ms 17752 KB Output is correct
8 Correct 5 ms 17912 KB Output is correct
9 Correct 6 ms 17752 KB Output is correct
10 Correct 5 ms 17752 KB Output is correct
11 Correct 5 ms 17752 KB Output is correct
12 Correct 5 ms 17752 KB Output is correct
13 Correct 5 ms 17752 KB Output is correct
14 Correct 5 ms 17752 KB Output is correct
15 Correct 5 ms 17752 KB Output is correct
16 Correct 5 ms 17752 KB Output is correct
17 Correct 5 ms 17752 KB Output is correct
18 Correct 5 ms 17752 KB Output is correct
19 Correct 5 ms 17752 KB Output is correct
20 Correct 5 ms 17752 KB Output is correct
21 Correct 5 ms 17752 KB Output is correct
22 Correct 5 ms 17752 KB Output is correct
23 Correct 5 ms 17752 KB Output is correct
24 Correct 8 ms 17752 KB Output is correct
25 Correct 6 ms 17752 KB Output is correct
26 Correct 6 ms 17752 KB Output is correct
27 Correct 6 ms 17752 KB Output is correct
28 Correct 6 ms 17752 KB Output is correct
29 Correct 6 ms 17752 KB Output is correct
30 Correct 16 ms 19396 KB Output is correct
31 Correct 8 ms 18712 KB Output is correct
32 Correct 25 ms 20260 KB Output is correct
33 Correct 21 ms 20340 KB Output is correct
34 Correct 1002 ms 21924 KB Output is correct
35 Correct 337 ms 20852 KB Output is correct
36 Correct 41 ms 20408 KB Output is correct
37 Correct 28 ms 20312 KB Output is correct
38 Correct 33 ms 19980 KB Output is correct
39 Correct 35 ms 20196 KB Output is correct
40 Correct 807 ms 22248 KB Output is correct
41 Correct 146 ms 20332 KB Output is correct
42 Correct 108 ms 20156 KB Output is correct
43 Correct 38 ms 21584 KB Output is correct
44 Correct 700 ms 22232 KB Output is correct
45 Correct 219 ms 30020 KB Output is correct
46 Correct 9 ms 18520 KB Output is correct
47 Correct 8 ms 18520 KB Output is correct
48 Correct 347 ms 46140 KB Output is correct
49 Correct 244 ms 37380 KB Output is correct
50 Execution timed out 4081 ms 47248 KB Time limit exceeded
51 Halted 0 ms 0 KB -