# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
984031 |
2024-05-16T09:27:30 Z |
vjudge1 |
Game (APIO22_game) |
C++17 |
|
1 ms |
600 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"
const int N = 3e3 + 9 , mod = 1e9 + 7;
int a[N][2] ;
int b[N][1009][2] , ind = 0;
vector<int>v[N][2];
int n , k;
int ans = 0 , ind1 = 0;
vector<int>v1;
void get(int x , int y , int f ){
a[x][y] = f;
for(auto to : v[x][y])
if(!a[to][y]){
get(to , y , f);
}else if((f < a[to][y] && y == 1) || (f > a[to][y]) && y == 0){
get(to , y , f);
}
}
void init(int n, int k){
::n = n , ::k = k;
for(int i = 1; i <= k; i++)
a[i][0] = a[i][1] = i;
}
int add_teleporter(int x , int y){
if(ans == 1)
return ans;
x++ , y++;
v[x][0].pb(y);
v[y][1].pb(x);
if(a[y][1] && a[y][1] <= a[x][0])
ans = 1;
if(a[y][1] && (a[y][1] < a[x][1] || a[x][1] == 0)){
get(x , 1 , a[y][1]);
}
if(a[x][0] && (a[x][0] > a[y][0] || a[y][0] == 0)){
get(y , 1 , a[x][0]);
}
return ans;
}
/*
int main(){
TL;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
init(6 , 3);
cout<<add_teleporter(3 , 4)<<"\n";
cout<<add_teleporter(5 , 0)<<"\n";
cout<<add_teleporter(4 , 5)<<"\n";
cout<<add_teleporter(5 , 3)<<"\n";
cout<<add_teleporter(1 , 4)<<"\n";
}*/
// Author : حسن
Compilation message
game.cpp: In function 'void get(int, int, int)':
game.cpp:36:61: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
36 | }else if((f < a[to][y] && y == 1) || (f > a[to][y]) && y == 0){
| ~~~~~~~~~~~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
Incorrect |
1 ms |
344 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |