답안 #707965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707965 2023-03-10T15:31:04 Z 600Mihnea 게임 (APIO22_game) C++17
100 / 100
1344 ms 69680 KB
#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 n;
int k;
vector<vector<int>> g, ig;
vector<pair<int, int>> range;

void init(int nn, int kk)
{
	n = nn;
	k = kk;
	g.clear();
	ig.clear();
	range.clear();
	g.resize(n + 1);
	ig.resize(n + 1);
	range.resize(n + 1);
	for (int i = 1; i <= k; i++)
	{
		range[i] = { i, i };
	}
	for (int i = k + 1; i <= n; i++)
	{
		range[i] = { 0, k + 1 };
	}
}

int upd(int from, int to)
{
	if (range[from].first >= range[to].second) return 1;
	if (range[from].second <= range[to].first) return 0;


	while (range[from].first > (range[to].first + range[to].second) / 2)
	{
		range[to].first = (range[to].first + range[to].second) / 2 + 1;
		for (auto& vertex : g[to])
		{
			if (upd(to, vertex))
			{
				return 1;
			}
		}
	}

	while (range[to].second <= (range[from].second + range[from].first) / 2)
	{
		range[from].second = (range[from].second + range[from].first) / 2;
		for (auto& vertex : ig[from])
		{
			if (upd(vertex, from))
			{
				return 1;
			}
		}
	}

	return 0;
}

int add_teleporter(int from, int to)
{
	from++;
	to++;
	assert(1 <= from && from <= n);
	assert(1 <= to && to <= n);

	g[from].push_back(to);
	ig[to].push_back(from);

	if (from >= to && from <= k) return 1;
	if (from == to) return 0;

	return upd(from, to);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 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 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 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 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 308 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 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 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 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 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 308 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 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 1 ms 464 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 2 ms 464 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 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 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 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 308 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 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 1 ms 464 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 2 ms 464 KB Output is correct
30 Correct 16 ms 2980 KB Output is correct
31 Correct 8 ms 2240 KB Output is correct
32 Correct 26 ms 6144 KB Output is correct
33 Correct 27 ms 3840 KB Output is correct
34 Correct 37 ms 8332 KB Output is correct
35 Correct 30 ms 5372 KB Output is correct
36 Correct 41 ms 3832 KB Output is correct
37 Correct 35 ms 3812 KB Output is correct
38 Correct 26 ms 3540 KB Output is correct
39 Correct 29 ms 3616 KB Output is correct
40 Correct 35 ms 8076 KB Output is correct
41 Correct 36 ms 4704 KB Output is correct
42 Correct 29 ms 4288 KB Output is correct
43 Correct 31 ms 5020 KB Output is correct
44 Correct 49 ms 4956 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 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 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 308 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 308 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 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 1 ms 464 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 2 ms 464 KB Output is correct
30 Correct 16 ms 2980 KB Output is correct
31 Correct 8 ms 2240 KB Output is correct
32 Correct 26 ms 6144 KB Output is correct
33 Correct 27 ms 3840 KB Output is correct
34 Correct 37 ms 8332 KB Output is correct
35 Correct 30 ms 5372 KB Output is correct
36 Correct 41 ms 3832 KB Output is correct
37 Correct 35 ms 3812 KB Output is correct
38 Correct 26 ms 3540 KB Output is correct
39 Correct 29 ms 3616 KB Output is correct
40 Correct 35 ms 8076 KB Output is correct
41 Correct 36 ms 4704 KB Output is correct
42 Correct 29 ms 4288 KB Output is correct
43 Correct 31 ms 5020 KB Output is correct
44 Correct 49 ms 4956 KB Output is correct
45 Correct 277 ms 28016 KB Output is correct
46 Correct 14 ms 17104 KB Output is correct
47 Correct 12 ms 17104 KB Output is correct
48 Correct 325 ms 45552 KB Output is correct
49 Correct 267 ms 35596 KB Output is correct
50 Correct 653 ms 54788 KB Output is correct
51 Correct 822 ms 46728 KB Output is correct
52 Correct 582 ms 35576 KB Output is correct
53 Correct 725 ms 35820 KB Output is correct
54 Correct 728 ms 35420 KB Output is correct
55 Correct 929 ms 35820 KB Output is correct
56 Correct 1092 ms 35516 KB Output is correct
57 Correct 485 ms 29384 KB Output is correct
58 Correct 452 ms 29440 KB Output is correct
59 Correct 479 ms 29588 KB Output is correct
60 Correct 449 ms 29444 KB Output is correct
61 Correct 591 ms 29428 KB Output is correct
62 Correct 447 ms 41872 KB Output is correct
63 Correct 359 ms 38448 KB Output is correct
64 Correct 994 ms 69680 KB Output is correct
65 Correct 457 ms 37448 KB Output is correct
66 Correct 378 ms 33264 KB Output is correct
67 Correct 841 ms 42860 KB Output is correct
68 Correct 200 ms 26244 KB Output is correct
69 Correct 68 ms 20196 KB Output is correct
70 Correct 739 ms 42516 KB Output is correct
71 Correct 310 ms 29016 KB Output is correct
72 Correct 300 ms 25052 KB Output is correct
73 Correct 674 ms 39344 KB Output is correct
74 Correct 1344 ms 35472 KB Output is correct
75 Correct 1078 ms 47316 KB Output is correct
76 Correct 1136 ms 54356 KB Output is correct