답안 #708936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708936 2023-03-12T19:11:21 Z 600Mihnea 게임 (APIO22_game) C++17
2 / 100
1 ms 292 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 <bitset>
#include <cassert>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>

using namespace std;

int n;
int k;
vector<vector<int>> g;
vector<vector<int>> ig;
vector<int> maxfrom;
vector<int> minto;

void init(int nn, int kk)
{
	n = nn;
	k = kk;

	g.clear();
	ig.clear();
	maxfrom.clear();
	minto.clear();

	g.resize(n + 1);
	ig.resize(n + 1);
	maxfrom.resize(n + 1);
	minto.resize(n + 1);

	for (int i = 1; i <= k; i++)
	{
		maxfrom[i] = minto[i] = i;
	}

	for (int i = k + 1; i <= n; i++)
	{
		maxfrom[i] = -1;
		minto[i] = k + 1;
	}
}

bool check(int from, int to)
{
	if (minto[to] < maxfrom[from]) return 1;

	if (minto[to] < minto[from])
	{
		minto[from] = minto[to];
		for (auto& vec : ig[from])
		{
			if (check(vec, from))
			{
				return 1;
			}
		}
	}

	if (maxfrom[from] > maxfrom[to])
	{
		maxfrom[to] = maxfrom[from];
		for (auto& vec : g[to])
		{
			if (check(to, vec))
			{
				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)
	{
		if (from <= k)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}

	if (to < from)
	{
		if (from <= k)
		{
			return 1;
		}
	}

	return check(from, to);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 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 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 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 0 ms 208 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 0 ms 208 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 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 0 ms 208 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 0 ms 208 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 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 0 ms 208 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 0 ms 208 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 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 0 ms 208 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 0 ms 208 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -