제출 #902259

#제출 시각아이디문제언어결과실행 시간메모리
902259Ghulam_Junaid게임 (IOI14_game)C++17
0 / 100
1 ms2648 KiB
#include <bits/stdc++.h> // #include "grader.cpp" using namespace std; const int MXN = 1505; int n, par[MXN], seen[MXN][MXN]; vector<int> S[MXN]; int root(int v){ return ((par[v] == -1) ? (v) : (par[v] = root(par[v]))); } void merge(int u, int v){ if ((u = root(u)) == (v = root(v))) return; if (S[u].size() > S[v].size()) swap(u, v); par[u] = v; for (int x : S[u]) S[v].push_back(x); S[u].clear(); } void initialize(int N){ n = N; for (int i=0; i<n; i++){ S[i].push_back(i); par[i] = -1; } } int hasEdge(int u, int v){ seen[u][v] = 1; u = root(u), v = root(v); if (u == v) return 0; int cnt = 0; for (int x : S[u]) for (int y : S[v]) cnt += seen[x][y]; if (cnt == (S[u].size() * S[v].size()) ){ merge(u, v); return 1; } return 0; } // int main(){ // 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; // } // }

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

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:44:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if (cnt == (S[u].size() * S[v].size()) ){
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...