Submission #708940

# Submission time Handle Problem Language Result Execution time Memory
708940 2023-03-12T19:23:53 Z 600Mihnea Game (APIO22_game) C++17
0 / 100
1 ms 208 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] <= k)
	{
		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 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -