Submission #984046

# Submission time Handle Problem Language Result Execution time Memory
984046 2024-05-16T09:32:20 Z vjudge1 Game (APIO22_game) C++17
60 / 100
956 ms 10076 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 = 1e5 + 9 , mod = 1e9 + 7;
int a[N][2] ;
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 , 0 , a[x][0]);
    }
    return ans;
}
/*
int main(){
    TL;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    init(4 , 2);
    cout<<add_teleporter(0 , 2)<<"\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:35:61: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   35 |         }else if((f < a[to][y] && y == 1) || (f > a[to][y]) && y == 0){
      |                                              ~~~~~~~~~~~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 5204 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 5144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 5204 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 5144 KB Output is correct
8 Correct 2 ms 5112 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4952 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 5204 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 5144 KB Output is correct
8 Correct 2 ms 5112 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4952 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4952 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 5208 KB Output is correct
23 Correct 2 ms 5208 KB Output is correct
24 Correct 4 ms 5208 KB Output is correct
25 Correct 4 ms 5464 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 2 ms 5208 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 3 ms 5464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 5204 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 5144 KB Output is correct
8 Correct 2 ms 5112 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4952 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4952 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 5208 KB Output is correct
23 Correct 2 ms 5208 KB Output is correct
24 Correct 4 ms 5208 KB Output is correct
25 Correct 4 ms 5464 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 2 ms 5208 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 3 ms 5464 KB Output is correct
30 Correct 16 ms 6820 KB Output is correct
31 Correct 5 ms 5828 KB Output is correct
32 Correct 17 ms 8068 KB Output is correct
33 Correct 12 ms 7256 KB Output is correct
34 Correct 956 ms 9288 KB Output is correct
35 Correct 334 ms 8424 KB Output is correct
36 Correct 34 ms 7680 KB Output is correct
37 Correct 28 ms 7136 KB Output is correct
38 Correct 22 ms 7212 KB Output is correct
39 Correct 20 ms 7000 KB Output is correct
40 Correct 885 ms 9072 KB Output is correct
41 Correct 151 ms 7684 KB Output is correct
42 Correct 100 ms 7568 KB Output is correct
43 Correct 30 ms 9304 KB Output is correct
44 Correct 689 ms 9304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 5204 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 5144 KB Output is correct
8 Correct 2 ms 5112 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4952 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4952 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 5208 KB Output is correct
23 Correct 2 ms 5208 KB Output is correct
24 Correct 4 ms 5208 KB Output is correct
25 Correct 4 ms 5464 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 2 ms 5208 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 3 ms 5464 KB Output is correct
30 Correct 16 ms 6820 KB Output is correct
31 Correct 5 ms 5828 KB Output is correct
32 Correct 17 ms 8068 KB Output is correct
33 Correct 12 ms 7256 KB Output is correct
34 Correct 956 ms 9288 KB Output is correct
35 Correct 334 ms 8424 KB Output is correct
36 Correct 34 ms 7680 KB Output is correct
37 Correct 28 ms 7136 KB Output is correct
38 Correct 22 ms 7212 KB Output is correct
39 Correct 20 ms 7000 KB Output is correct
40 Correct 885 ms 9072 KB Output is correct
41 Correct 151 ms 7684 KB Output is correct
42 Correct 100 ms 7568 KB Output is correct
43 Correct 30 ms 9304 KB Output is correct
44 Correct 689 ms 9304 KB Output is correct
45 Runtime error 5 ms 10076 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -