제출 #289765

#제출 시각아이디문제언어결과실행 시간메모리
289765ivan24게임 (IOI14_game)C++14
42 / 100
1053 ms1656 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; using ll = int; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef vector<vii> vvii; #define F first #define S second const ll INF = 1e9; ll max(ll x, ll y){ return ((x > y) ? x : y); } ll min(ll x, ll y){ return ((x < y) ? x : y); } class UnionFind { private: ll n, connected_cnt; vi sz,p; public: UnionFind(){} UnionFind (ll n): n(n), sz(n,1), p(n), connected_cnt(n){ for (ll i = 0; n > i; i++) p[i] = i; } ll root (ll x){ if (p[x] != x) p[x] = root(p[x]); return p[x]; } void unify (ll x, ll y){ x = root(x), y = root(y); if (x == y) return; if (sz[x] < sz[y]) swap(x,y); p[y] = x; sz[x] += sz[y]; connected_cnt--; } ll get_connected_cnt(){ return connected_cnt; } }; class Solver{ private: ll n; vvi adjMatrix; UnionFind uf; bool isUnited(){ queue<ll> q; vi isVisited(n,0); q.push(0); isVisited[0] = 1; while (!q.empty()){ ll v = q.front(); q.pop(); for (ll i = 0; n > i; i++){ if (adjMatrix[v][i] && !isVisited[i]){ isVisited[i] = 1; q.push(i); } } } for (ll i = 0; n > i; i++) if (!isVisited[i]) return false; return true; } void setEdge(ll u, ll v, ll val){ adjMatrix[u][v] = val; adjMatrix[v][u] = val; } public: Solver(){} Solver(ll n): n (n), adjMatrix(n,vi(n,-1)){ uf = UnionFind(n); } ll hasEdge(ll u, ll v){ setEdge(u,v,0); if (!isUnited()){ setEdge(u,v,1); return 1; }else return 0; } }; Solver mySolver; void initialize(int n) { mySolver = Solver(n); } int hasEdge(int u, int v) { return mySolver.hasEdge(u,v); }

컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In constructor 'UnionFind::UnionFind(ll)':
game.cpp:25:11: warning: 'UnionFind::p' will be initialized after [-Wreorder]
   25 |     vi sz,p;
      |           ^
game.cpp:24:11: warning:   'll UnionFind::connected_cnt' [-Wreorder]
   24 |     ll n, connected_cnt;
      |           ^~~~~~~~~~~~~
game.cpp:28:5: warning:   when initialized here [-Wreorder]
   28 |     UnionFind (ll n): n(n), sz(n,1), p(n), connected_cnt(n){
      |     ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...