Submission #708941

# Submission time Handle Problem Language Result Execution time Memory
708941 2023-03-12T19:26:46 Z 600Mihnea Game (APIO22_game) C++17
60 / 100
4000 ms 41468 KB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "game.h"

#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 <bitset>
#include <cassert>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>

using namespace std;

bool F;
int n;
int k;
vector<vector<int>> g;
vector<vector<int>> ig;
vector<int> minAjung;

void init(int nn, int kk)
{
	F = 0;
	n = nn;
	k = kk;
	minAjung.clear();
	g.clear();
	ig.clear();

	g.resize(n + 1);
	ig.resize(n + 1);
	minAjung.resize(n + 1);
	for (int i = 1; i <= n; i++)
	{
		minAjung[i] = k + 1;
	}
}

void upd(int from)
{
	if (F)
	{
		return;
	}
	if (from <= k && minAjung[from] <= from)
	{
		F = 1;
	}
	for (auto& vec : ig[from])
	{
		if (minAjung[from] < minAjung[vec])
		{
			minAjung[vec] = minAjung[from];
			upd(vec);
		}
	}
}

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);

	{
		int val = ((to <= k) ? (to) : (minAjung[to]));
		if (val < minAjung[from])
		{
			minAjung[from] = val;
			upd(from);
		}
	}
	
	return F;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 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 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 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 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 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 4 ms 336 KB Output is correct
25 Correct 4 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 3 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 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 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 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 4 ms 336 KB Output is correct
25 Correct 4 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 3 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 15 ms 2956 KB Output is correct
31 Correct 4 ms 2128 KB Output is correct
32 Correct 19 ms 4312 KB Output is correct
33 Correct 16 ms 3636 KB Output is correct
34 Correct 560 ms 5136 KB Output is correct
35 Correct 207 ms 4216 KB Output is correct
36 Correct 31 ms 3640 KB Output is correct
37 Correct 29 ms 3664 KB Output is correct
38 Correct 24 ms 3344 KB Output is correct
39 Correct 23 ms 3400 KB Output is correct
40 Correct 440 ms 5092 KB Output is correct
41 Correct 94 ms 3868 KB Output is correct
42 Correct 62 ms 3728 KB Output is correct
43 Correct 32 ms 5104 KB Output is correct
44 Correct 468 ms 5048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 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 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 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 4 ms 336 KB Output is correct
25 Correct 4 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 3 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 15 ms 2956 KB Output is correct
31 Correct 4 ms 2128 KB Output is correct
32 Correct 19 ms 4312 KB Output is correct
33 Correct 16 ms 3636 KB Output is correct
34 Correct 560 ms 5136 KB Output is correct
35 Correct 207 ms 4216 KB Output is correct
36 Correct 31 ms 3640 KB Output is correct
37 Correct 29 ms 3664 KB Output is correct
38 Correct 24 ms 3344 KB Output is correct
39 Correct 23 ms 3400 KB Output is correct
40 Correct 440 ms 5092 KB Output is correct
41 Correct 94 ms 3868 KB Output is correct
42 Correct 62 ms 3728 KB Output is correct
43 Correct 32 ms 5104 KB Output is correct
44 Correct 468 ms 5048 KB Output is correct
45 Correct 225 ms 26956 KB Output is correct
46 Correct 17 ms 15936 KB Output is correct
47 Correct 11 ms 15952 KB Output is correct
48 Correct 288 ms 41468 KB Output is correct
49 Correct 315 ms 34288 KB Output is correct
50 Execution timed out 4078 ms 32016 KB Time limit exceeded
51 Halted 0 ms 0 KB -