Submission #502875

#TimeUsernameProblemLanguageResultExecution timeMemory
502875Urvuk3Game (IOI14_game)C++17
0 / 100
114 ms262148 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN=1505;
#define ll long long
#define MAXN 10000
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),b.begin()
#define mod 1000000007LL
#define endl "\n"
#define PRINT(x) cout<<#x<<'-'<<x<<endl

ll n,res=0;

int dsu[MAXN],sz[MAXN];
vector<vector<int>> cnt(MAXN,vector<int>(MAXN,0));

int root(int x){
    while(x!=dsu[x]){
        dsu[x]=dsu[dsu[x]];
        x=dsu[x];
    }
}

void initialize(int n){
    iota(dsu,dsu+MAXN+1,0);
    fill(sz,sz+MAXN+1,1);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                cnt[i][j]=1;
                cnt[j][i]=1;
            }
        }
    }
}

int hasEdge(int u, int v){
    if(cnt[u][v]==1){
        cnt[u][v]=0;
        cnt[v][u]=0;
        for(int k=0;k<n;k++){
            if(k!=u && k!=v){
                cnt[u][k]+=cnt[v][k];
                cnt[k][u]+=cnt[v][k];
                cnt[v][k]+=cnt[u][k];
                cnt[k][v]+=cnt[u][k];
            }
        }
        return 1;
    }
    else{
        cnt[u][v]--;
        cnt[v][u]--;
        return 0;
    }
}

Compilation message (stderr)

game.cpp: In function 'int root(int)':
game.cpp:30:1: warning: no return statement in function returning non-void [-Wreturn-type]
   30 | }
      | ^
game.cpp: In function 'void initialize(int)':
game.cpp:33:9: warning: array subscript 10001 is outside array bounds of 'int [10000]' [-Warray-bounds]
   33 |     iota(dsu,dsu+MAXN+1,0);
      |     ~~~~^~~~~~~~~~~~~~~~~~
game.cpp:22:5: note: while referencing 'dsu'
   22 | int dsu[MAXN],sz[MAXN];
      |     ^~~
game.cpp:34:9: warning: array subscript 10001 is outside array bounds of 'int [10000]' [-Warray-bounds]
   34 |     fill(sz,sz+MAXN+1,1);
      |     ~~~~^~~~~~~~~~~~~~~~
game.cpp:22:15: note: while referencing 'sz'
   22 | int dsu[MAXN],sz[MAXN];
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...