Submission #892753

#TimeUsernameProblemLanguageResultExecution timeMemory
892753raul2008487Game (IOI14_game)C++17
15 / 100
1 ms4540 KiB
#include<bits/stdc++.h> #define ll long long #define vl vector<ll> #include "game.h" using namespace std; const int sz = 1505; ll a[sz][sz]; struct DSU{ vl e, ne; void init(ll n){ e.assign(n+1, -1); ne.assign(n+1, 0); } ll base(ll x){ if(e[x] < 0){ return x; } return e[x] = base(e[x]); } bool unite(ll x, ll y){ x = base(x); y = base(y); bool as = 0; if(x == y){assert(0);} if(e[x] > e[y]){ swap(x, y); } a[x][y]++; a[y][x]++; ll nume = ne[x] + ne[y] + a[x][y]; ll cd = e[x] + e[y]; ll fe = (cd * (cd + 1) / 2); if(nume == fe){ e[x] += e[y]; e[y] = x; ne[x] = fe; return true; } else{ return 0; } } }; DSU dsu; void initialize(int n) { dsu.init(n); ll i, j; for(i=0;i<n;i++){ for(j=0;j<n;j++){ a[i][j] = 0; } } } int hasEdge(int u, int v) { if(dsu.unite(u, v)){ return 1; } return 0; }

Compilation message (stderr)

game.cpp: In member function 'bool DSU::unite(long long int, long long int)':
game.cpp:23:14: warning: unused variable 'as' [-Wunused-variable]
   23 |         bool as = 0;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...