Submission #984979

# Submission time Handle Problem Language Result Execution time Memory
984979 2024-05-17T08:53:16 Z Kinoko_Sokora Game (APIO22_game) C++17
60 / 100
4000 ms 18432 KB
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include<iomanip>
#include<queue>
#include<set>
#include<functional>
#include<tuple>
#include<bitset>
#include<cassert>
#include<cstdint>
#include<complex>
#include<random>
#include<fstream>
#include <unordered_map>  
#include <unordered_set>  
using namespace std;
bool printb(bool f) {
	if (f)printf("Yes\n");
	else printf("No\n");
	return f;
}
template<class T>
void prt(T t = "", string sep = "\n") { cout << t << sep; return; }
template<class T>
void printl(vector<T> a, string sep = " ") {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i != a.size() - 1)cout << sep;
	}
	cout << "\n";
	return;
}

bool prt_isfixed = false;
template<class T>
void prt_fix(T t, string sep = "\n") {
	if (!prt_isfixed) {
		cout << fixed << setprecision(15);
		prt_isfixed = true;
	}
	prt(t, sep);
}
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#pragma GCC target "prefer-vector-width=512"
#pragma GCC optimize "Ofast"
#pragma GCC optimize("unroll-loops")

using uint = unsigned int;
using llong = long long;
using ullong = unsigned long long;
using pii = pair<int, int>;
using pll = pair<llong, llong>;
using pli = pair<llong, int>;
using pil = pair<int, llong>;
template<typename T> using vec2 = vector<vector<T>>;
template<typename T> inline bool chmin(T& a, T b) { return (a > b) ? (a = b, true) : false; }
template<typename T> inline bool chmax(T& a, T b) { return (a < b) ? (a = b, true) : false; }
bool bitIn(llong a, int b) { return ((a >> b) & 1); }
int bitCnt(llong a) {
	int re = 0;
	while (a > 0) {
		if (a & 1)re++;
		a >>= 1;
	}
	return re;
}
llong powL(llong n, llong i) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) re *= n;
		n *= n;
		i >>= 1;
	}
	return re;
}
llong powL_M(llong n, llong i, llong mod) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) {
			re *= n;
			re %= mod;
		}
		n *= n;
		n %= mod;
		i >>= 1;
	}
	return re;
}


llong cei(llong a, llong b) {
	if (a % b == 0)return a / b;
	else if (a < 0) {
		return a / b;
	}
	else {
		return a / b + 1;
	}
}

llong flo(llong a, llong b) {
	if (a % b == 0)return a / b;
	else if (a < 0) {
		return a / b - 1;
	}
	else {
		return a / b;
	}
}
int  dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int  dx2[8] = { -1,-1,1,1,-1,-1,1,1 }, dy2[8] = { 1,-1,-1,1,1,-1,-1,1 };
int dx8[8] = { 0,1,1,1,0,-1,-1,-1 }, dy8[8] = { -1,-1,0,1,1,1,0,-1 };

#include "game.h"

vector<int> num;
vec2<int> g;
int n, k;
void init(int nn, int kk) {
	n = nn;
	k = kk;
	num.resize(n, -1);
	rep(i, k)num[i] = i;
	g.resize(n);
}

int add_teleporter(int u, int v) {
	g[u].push_back(v);
	if (v < k && num[u] >= v)return 1;
	if (!chmax(num[v], num[u])) {
		return 0;
	}
	queue<int> q;
	q.emplace(v);
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (auto i : g[x]) {
			if (i < k && num[x] >= i)return 1;
			if (chmax(num[i], num[x])) {
				q.emplace(i);
			}
		}
	}
	return 0;
}

/*
int main() {
	int n, m, k;
	cin >> n  >> k;
	init(n, k);
	while(true){
		int u, v;
		cin >> u >> v;
		if (u == -1)break;
		prt(add_teleporter(u, v));
	}
}//*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 516 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 516 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 616 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 516 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 616 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 472 KB Output is correct
30 Correct 10 ms 1880 KB Output is correct
31 Correct 4 ms 1876 KB Output is correct
32 Correct 13 ms 2824 KB Output is correct
33 Correct 12 ms 2648 KB Output is correct
34 Correct 471 ms 2424 KB Output is correct
35 Correct 171 ms 2492 KB Output is correct
36 Correct 23 ms 2744 KB Output is correct
37 Correct 22 ms 2144 KB Output is correct
38 Correct 21 ms 2392 KB Output is correct
39 Correct 22 ms 2392 KB Output is correct
40 Correct 378 ms 2300 KB Output is correct
41 Correct 78 ms 2180 KB Output is correct
42 Correct 53 ms 2136 KB Output is correct
43 Correct 29 ms 2912 KB Output is correct
44 Correct 176 ms 2432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 516 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 616 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 472 KB Output is correct
30 Correct 10 ms 1880 KB Output is correct
31 Correct 4 ms 1876 KB Output is correct
32 Correct 13 ms 2824 KB Output is correct
33 Correct 12 ms 2648 KB Output is correct
34 Correct 471 ms 2424 KB Output is correct
35 Correct 171 ms 2492 KB Output is correct
36 Correct 23 ms 2744 KB Output is correct
37 Correct 22 ms 2144 KB Output is correct
38 Correct 21 ms 2392 KB Output is correct
39 Correct 22 ms 2392 KB Output is correct
40 Correct 378 ms 2300 KB Output is correct
41 Correct 78 ms 2180 KB Output is correct
42 Correct 53 ms 2136 KB Output is correct
43 Correct 29 ms 2912 KB Output is correct
44 Correct 176 ms 2432 KB Output is correct
45 Correct 144 ms 14612 KB Output is correct
46 Correct 6 ms 9048 KB Output is correct
47 Correct 4 ms 9048 KB Output is correct
48 Correct 189 ms 18160 KB Output is correct
49 Correct 142 ms 18432 KB Output is correct
50 Execution timed out 4073 ms 14056 KB Time limit exceeded
51 Halted 0 ms 0 KB -