답안 #707650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707650 2023-03-09T16:11:34 Z 600Mihnea 게임 (APIO22_game) C++17
30 / 100
4000 ms 5564 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 rad;

int getbucket(int x)
{
	return x / rad;
}

int n, k;
vector<vector<int>> g, ig;
vector<int> mn, mn2,isprec;
bool is;

void addedge(int from, int to)
{
	isprec[from] |= isprec[to];
	g[from].push_back(to);
	ig[to].push_back(from);
}

void init(int nn, int kk)
{
	is = 0;
	n = nn;
	k = kk;
	rad = sqrt(n) + 2;

	g.clear();
	g.resize(n);
	ig.clear();
	ig.resize(n);

	mn.clear();
	mn.resize(n, +INF);

	mn2.clear();
	mn2.resize(n, +INF);

	isprec.clear();
	isprec.resize(n, 0);

	for (int i = 0; i + 1 < k; i++)
	{
		//addedge(i, i + 1);
	}
}

void toggle(int a)
{

}

void upd(int a, int value, int esteprec)
{
	
	if (is)
	{
		return;
	}
	assert(esteprec == 0 || esteprec == 1);
	if (esteprec == 1)
	{
		//if (!isprec[a] && a >= k) return;

		if (value < mn[a])
		{
			mn[a] = value;
			if (a < k && mn[a] <= a)
			{
				is = 1;
				return;
			}
			for (auto& b : ig[a])
			{
				upd(b, mn[a], 1);
			}
		}
		return;
	}
	assert(esteprec == 0);
	if (value < mn2[a])
	{
		mn2[a] = value;
		for (auto& b : ig[a])
		{
			upd(b, mn2[a], 0);
		}
		if (a < k)
		{
			if (mn2[a] < getbucket(a))
			{
				is = 1;
				return;
			}
			if (mn2[a] == getbucket(a))
			{
				return;
				isprec[a] = 1;
				for (auto& b : g[a])
				{
					//cout << "a = " << a << " : " << b << "\n";
					if (b < k)
					{
						upd(a, b, 1);
					}
					else
					{
						upd(a, mn[b], 1);
					}
				}
			}
		}
	}
}

int add_teleporter(int from, int to)
{
	addedge(from, to);
	if (to < k)
	{
		upd(from, to, 1);
		upd(from, getbucket(to), 0);
	}
	else
	{
		upd(from, mn[to], 1);
		upd(from, mn2[to], 0);
	}
	//cout << "finished adding " << from << " " << to << "\n";
	if (is)
	{
		return 1;
	}
	for (int i = 0; i < n; i++)
	{
		if (mn[i] != INF)
		{
			//cout << i << " : " << getbucket(mn[i]) << " vs " << mn2[i] << "\n";
			assert(mn2[i] == getbucket(mn[i]));
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 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 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 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 3 ms 364 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 6 ms 336 KB Output is correct
25 Correct 12 ms 404 KB Output is correct
26 Correct 15 ms 360 KB Output is correct
27 Correct 18 ms 380 KB Output is correct
28 Correct 5 ms 380 KB Output is correct
29 Correct 12 ms 420 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 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 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 3 ms 364 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 6 ms 336 KB Output is correct
25 Correct 12 ms 404 KB Output is correct
26 Correct 15 ms 360 KB Output is correct
27 Correct 18 ms 380 KB Output is correct
28 Correct 5 ms 380 KB Output is correct
29 Correct 12 ms 420 KB Output is correct
30 Correct 929 ms 3216 KB Output is correct
31 Correct 259 ms 2376 KB Output is correct
32 Correct 930 ms 4672 KB Output is correct
33 Correct 1012 ms 3976 KB Output is correct
34 Correct 1609 ms 5292 KB Output is correct
35 Correct 3286 ms 4672 KB Output is correct
36 Correct 2471 ms 3980 KB Output is correct
37 Correct 2512 ms 3992 KB Output is correct
38 Correct 3501 ms 3916 KB Output is correct
39 Correct 3726 ms 3736 KB Output is correct
40 Correct 2805 ms 5564 KB Output is correct
41 Correct 3251 ms 4272 KB Output is correct
42 Execution timed out 4002 ms 4076 KB Time limit exceeded
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 0 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 3 ms 364 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 6 ms 336 KB Output is correct
25 Correct 12 ms 404 KB Output is correct
26 Correct 15 ms 360 KB Output is correct
27 Correct 18 ms 380 KB Output is correct
28 Correct 5 ms 380 KB Output is correct
29 Correct 12 ms 420 KB Output is correct
30 Correct 929 ms 3216 KB Output is correct
31 Correct 259 ms 2376 KB Output is correct
32 Correct 930 ms 4672 KB Output is correct
33 Correct 1012 ms 3976 KB Output is correct
34 Correct 1609 ms 5292 KB Output is correct
35 Correct 3286 ms 4672 KB Output is correct
36 Correct 2471 ms 3980 KB Output is correct
37 Correct 2512 ms 3992 KB Output is correct
38 Correct 3501 ms 3916 KB Output is correct
39 Correct 3726 ms 3736 KB Output is correct
40 Correct 2805 ms 5564 KB Output is correct
41 Correct 3251 ms 4272 KB Output is correct
42 Execution timed out 4002 ms 4076 KB Time limit exceeded
43 Halted 0 ms 0 KB -