Submission #733774

# Submission time Handle Problem Language Result Execution time Memory
733774 2023-05-01T09:29:52 Z minhcool Game (APIO22_game) C++17
2 / 100
9 ms 14384 KB
#include<bits/stdc++.h>
using namespace std;

//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, k;

vector<int> Adj[N], Adj2[N];

int mn[N], mx[N];

void init(int n_, int k_){
	n = n_, k = k_;
	for(int i = 0; i < n; i++){
		mn[i] = oo, mx[i] = -oo;
	}
	for(int i = 0; i <= (k - 2); i++){
		Adj[i].pb(i + 1);
		Adj2[i + 1].pb(i);
	}
	for(int i = 0; i < k; i++){
		if(i >= 1) mx[i] = i - 1;
		if(i != (k - 1)) mn[i] = i + 1;
	}
}

//int mx[N], mn[N];// have path from mx[] -> x, x -> mn[]

bool ck = 0;

//vector<int> Adj2[N];

void upd1(int u){
	ck |= (mx[u] >= mn[u]);
	for(auto v : Adj[u]){
		if(mx[v] < mx[u]){
			mx[v] = mx[u];
			upd1(v);		
		}
	}
}

void upd2(int u){
	ck |= (mx[u] >= mn[u]);
	for(auto v : Adj2[u]){
		if(mn[v] > mn[u]){
			mn[v] = mn[u];
			upd2(v);
		}
	}
}

int add_teleporter(int x, int y){
	Adj[x].pb(y);
	Adj2[y].pb(x);
	if(x < k && y < k){
		if(x >= y) ck = 1;
	}
	else if(x < k){
		mx[y] = max(mx[y], x);
	}
	else if(y < k){
		mn[y] = min(mn[y], x);
	}
	upd1(x);
	upd1(y);
	upd2(x);
	upd2(y);
//	for(int i = 0; i < n; i++) cout << mn[i] << " " << mx[i] << "\n";
	return ck;
}

Compilation message

game.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14384 KB Output is correct
2 Correct 9 ms 14344 KB Output is correct
3 Correct 8 ms 14352 KB Output is correct
4 Correct 8 ms 14368 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 8 ms 14364 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14384 KB Output is correct
2 Correct 9 ms 14344 KB Output is correct
3 Correct 8 ms 14352 KB Output is correct
4 Correct 8 ms 14368 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 8 ms 14364 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Incorrect 8 ms 14288 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14384 KB Output is correct
2 Correct 9 ms 14344 KB Output is correct
3 Correct 8 ms 14352 KB Output is correct
4 Correct 8 ms 14368 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 8 ms 14364 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Incorrect 8 ms 14288 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14384 KB Output is correct
2 Correct 9 ms 14344 KB Output is correct
3 Correct 8 ms 14352 KB Output is correct
4 Correct 8 ms 14368 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 8 ms 14364 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Incorrect 8 ms 14288 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14384 KB Output is correct
2 Correct 9 ms 14344 KB Output is correct
3 Correct 8 ms 14352 KB Output is correct
4 Correct 8 ms 14368 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 8 ms 14364 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Incorrect 8 ms 14288 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -