Submission #605031

# Submission time Handle Problem Language Result Execution time Memory
605031 2022-07-25T12:23:01 Z HediChehaidar Game (IOI14_game) C++17
100 / 100
415 ms 28256 KB
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd  pair<double,double>
#define vdd  vector<pdd>
#define dte  tuple<double , double , double>
using namespace std;
const int INF = 1000*1000*1000; // 1 e 9
const int MOD = 1e9 + 7;//998244353 ;
const double EPS = 0.000000001; // 1 e -9
const ll inf = (ll)2e18;

int cur ;
int g[2020][2020];
int nb[2020];
int n;
set<int> s;
int id[2020];
int ran[2020];
int getid(int x){
    return id[x] == x ? x : id[x] = getid(id[x]);
}
void uni(int x , int y){
    x = getid(x); y = getid(y);
    if(ran[x] > ran[y]) swap(x , y);
    ran[y] += ran[x];
    for(int c = 0 ; c < n ; c++) g[y][c] = g[c][y] = g[c][y] + g[c][x];
    for(int i = 0 ; i < n ; i++) g[x][i] = g[i][x] = 0;
    id[x] = y;
}
int hasEdge(int u, int v){
    u = getid(u); v = getid(v);
    if(g[u][v] > 1){
        g[u][v]--; g[v][u]--; return 0;
    }
    assert(g[u][v] == 1);
    g[u][v] = g[v][u] = 0;
    uni(u , v);
    return 1;
}
void initialize(int N){
    n = N;
    for(int i = 0 ; i < n ; i++) {
        for(int j = 0 ; j < n ; j++){
            g[i][j] = g[j][i] = 1;
        }
    }
    for(int i = 0 ; i < n ; i++) g[i][i] = 0;
    for(int i = 0 ; i < n ; i++) {
        id[i] = i; ran[i] = 1;
    }
}
/*int main(){
    //ifstream fin ("testing.txt");
    //ofstream fout ("output.txt");
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n; cin>>n;
    initialize(n);
    for(int i = 0 ; i < (n * (n - 1)) / 2 ; i++){
        int u , v; cin>>u>>v; cout<< hasEdge(u , v) << endl;
    }
    return 0;
}
*/
/*
    Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO / HLD
    Read the statement CAREFULLY !!
    Make a GREADY APPROACH !!!! (start from highest / lowest)
    Make your own TESTS !!
    Be careful from CORNER CASES !
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 244 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 440 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 2 ms 708 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 596 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 1 ms 692 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 2 ms 596 KB Output is correct
43 Correct 1 ms 596 KB Output is correct
44 Correct 1 ms 596 KB Output is correct
45 Correct 1 ms 596 KB Output is correct
46 Correct 1 ms 708 KB Output is correct
47 Correct 1 ms 596 KB Output is correct
48 Correct 1 ms 596 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 1 ms 596 KB Output is correct
51 Correct 1 ms 596 KB Output is correct
52 Correct 2 ms 596 KB Output is correct
53 Correct 2 ms 708 KB Output is correct
54 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 312 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 444 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 692 KB Output is correct
37 Correct 1 ms 696 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 1 ms 596 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 1 ms 596 KB Output is correct
48 Correct 1 ms 596 KB Output is correct
49 Correct 1 ms 596 KB Output is correct
50 Correct 1 ms 708 KB Output is correct
51 Correct 2 ms 596 KB Output is correct
52 Correct 1 ms 596 KB Output is correct
53 Correct 1 ms 596 KB Output is correct
54 Correct 1 ms 712 KB Output is correct
55 Correct 40 ms 5056 KB Output is correct
56 Correct 37 ms 5056 KB Output is correct
57 Correct 35 ms 5196 KB Output is correct
58 Correct 34 ms 5116 KB Output is correct
59 Correct 32 ms 5092 KB Output is correct
60 Correct 34 ms 5068 KB Output is correct
61 Correct 40 ms 5040 KB Output is correct
62 Correct 35 ms 5068 KB Output is correct
63 Correct 33 ms 5076 KB Output is correct
64 Correct 31 ms 5056 KB Output is correct
65 Correct 32 ms 5148 KB Output is correct
66 Correct 50 ms 5152 KB Output is correct
67 Correct 33 ms 5068 KB Output is correct
68 Correct 33 ms 5072 KB Output is correct
69 Correct 38 ms 5152 KB Output is correct
70 Correct 33 ms 5108 KB Output is correct
71 Correct 32 ms 5028 KB Output is correct
72 Correct 31 ms 5060 KB Output is correct
73 Correct 37 ms 5072 KB Output is correct
74 Correct 33 ms 5076 KB Output is correct
75 Correct 44 ms 5052 KB Output is correct
76 Correct 84 ms 9732 KB Output is correct
77 Correct 81 ms 9740 KB Output is correct
78 Correct 88 ms 9788 KB Output is correct
79 Correct 81 ms 9764 KB Output is correct
80 Correct 80 ms 9836 KB Output is correct
81 Correct 84 ms 9756 KB Output is correct
82 Correct 92 ms 9816 KB Output is correct
83 Correct 81 ms 9760 KB Output is correct
84 Correct 88 ms 9804 KB Output is correct
85 Correct 167 ms 15524 KB Output is correct
86 Correct 163 ms 15496 KB Output is correct
87 Correct 151 ms 15436 KB Output is correct
88 Correct 151 ms 15504 KB Output is correct
89 Correct 155 ms 15528 KB Output is correct
90 Correct 148 ms 15524 KB Output is correct
91 Correct 151 ms 15488 KB Output is correct
92 Correct 151 ms 15428 KB Output is correct
93 Correct 159 ms 15492 KB Output is correct
94 Correct 379 ms 28136 KB Output is correct
95 Correct 415 ms 28192 KB Output is correct
96 Correct 373 ms 28116 KB Output is correct
97 Correct 405 ms 28148 KB Output is correct
98 Correct 373 ms 28256 KB Output is correct
99 Correct 415 ms 28108 KB Output is correct
100 Correct 369 ms 28112 KB Output is correct