Submission #381674

#TimeUsernameProblemLanguageResultExecution timeMemory
381674Aryan_RainaGame (IOI14_game)C++14
42 / 100
1092 ms1132 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include "game.h" #include<bits/stdc++.h> using namespace std; struct UFDS { int n, cc; vector<int> len, par; void init(int x) { n = cc = x; par.resize(n+2); len.assign(n+2, 1); iota(par.begin(), par.end(), 0); } int fin(int v) { return par[v] == v ? v : par[v] = fin(par[v]); } bool join(int a, int b) { a = fin(a); b = fin(b); if(a == b) return false; if(len[a] < len[b]) swap(a, b); par[b] = a; len[a]+=len[b]; cc--; return true; } }; int n; bool adj[1505][1501]; void initialize(int _n) { n = _n; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) adj[i][j] = adj[j][i] = 1; } } int hasEdge(int u, int v) { if (u < v) swap(u, v); UFDS ufds; ufds.init(n); for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) if (!(i == u && j == v) && adj[i][j]) { ufds.join(i, j); } } if (ufds.cc == 1) { adj[u][v] = adj[v][u] = 0; return 0; } else { return 1; } }

Compilation message (stderr)

game.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
game.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...