답안 #709393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709393 2023-03-13T13:56:05 Z 600Mihnea 게임 (APIO22_game) C++17
60 / 100
4000 ms 43564 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] = { 0, k + 1 };
	}
	for (int i = k + 1; i <= n; i++)
	{
		range[i] = { 0, k + 1 };
	}
}

int upd(int from, int to)
{
	{
		int val = (from <= k) ? (from) : range[from].first;
		if (val > range[to].first)
		{
			range[to].first = val;
			for (auto& vertex : g[to])
			{
				if (upd(to, vertex))
				{
					return 1;
				}
			}
		}
	}
	{
		int val = (to <= k) ? (to) : range[to].second;
		if (val < range[from].second)
		{
			range[from].second = val;
			for (auto& vertex : ig[from])
			{
				if (upd(vertex, from))
				{
					return 1;
				}
			}
		}
	}

	if (range[to].second < range[from].second)
	{
		range[from].second = range[to].second;
		for (auto& vertex : ig[from])
		{
			if (upd(vertex, from))
			{
				return 1;
			}
		}
	}
	if (range[from].first >= range[from].second) return 1;
	if (range[to].first >= range[to].second) 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 1 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 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 1 ms 208 KB Output is correct
7 Correct 1 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 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 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 1 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 1 ms 208 KB Output is correct
7 Correct 1 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 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 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 5 ms 336 KB Output is correct
25 Correct 5 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 1 ms 208 KB Output is correct
7 Correct 1 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 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 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 5 ms 336 KB Output is correct
25 Correct 5 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 16 ms 3076 KB Output is correct
31 Correct 5 ms 2348 KB Output is correct
32 Correct 23 ms 4080 KB Output is correct
33 Correct 17 ms 3780 KB Output is correct
34 Correct 2809 ms 5724 KB Output is correct
35 Correct 680 ms 4480 KB Output is correct
36 Correct 55 ms 3704 KB Output is correct
37 Correct 51 ms 3756 KB Output is correct
38 Correct 49 ms 3548 KB Output is correct
39 Correct 37 ms 3568 KB Output is correct
40 Correct 1118 ms 5588 KB Output is correct
41 Correct 241 ms 4064 KB Output is correct
42 Correct 139 ms 3884 KB Output is correct
43 Correct 57 ms 5732 KB Output is correct
44 Correct 1406 ms 5688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 1 ms 208 KB Output is correct
7 Correct 1 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 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 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 5 ms 336 KB Output is correct
25 Correct 5 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 16 ms 3076 KB Output is correct
31 Correct 5 ms 2348 KB Output is correct
32 Correct 23 ms 4080 KB Output is correct
33 Correct 17 ms 3780 KB Output is correct
34 Correct 2809 ms 5724 KB Output is correct
35 Correct 680 ms 4480 KB Output is correct
36 Correct 55 ms 3704 KB Output is correct
37 Correct 51 ms 3756 KB Output is correct
38 Correct 49 ms 3548 KB Output is correct
39 Correct 37 ms 3568 KB Output is correct
40 Correct 1118 ms 5588 KB Output is correct
41 Correct 241 ms 4064 KB Output is correct
42 Correct 139 ms 3884 KB Output is correct
43 Correct 57 ms 5732 KB Output is correct
44 Correct 1406 ms 5688 KB Output is correct
45 Correct 287 ms 28088 KB Output is correct
46 Correct 16 ms 17196 KB Output is correct
47 Correct 14 ms 17128 KB Output is correct
48 Correct 363 ms 43564 KB Output is correct
49 Correct 316 ms 35480 KB Output is correct
50 Execution timed out 4102 ms 35512 KB Time limit exceeded
51 Halted 0 ms 0 KB -