제출 #933317

#제출 시각아이디문제언어결과실행 시간메모리
933317SmuggingSpun게임 (IOI14_game)C++14
100 / 100
276 ms26456 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; const int lim = 1505; int n, p[lim], sz[lim], cnt[lim][lim]; int find_set(int n){ return n == p[n] ? n : p[n] = find_set(p[n]); } void merge(int a, int b){ if(sz[a = find_set(a)] < sz[b = find_set(b)]){ swap(a, b); } sz[p[b] = a] += sz[b]; for(int i = 0; i < n; i++){ cnt[a][i] += cnt[b][i]; cnt[i][a] += cnt[b][i]; } } void initialize(int N){ iota(p, p + (n = N), 0); fill(sz, sz + n, 1); memset(cnt, 0, sizeof(cnt)); } int hasEdge(int u, int v){ if(sz[u = find_set(u)] * sz[v = find_set(v)] - 1 == cnt[u][v]){ merge(u, v); return 1; } cnt[u][v]++; cnt[v][u]++; return 0; }

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

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:25:32: warning: operation on 'v' may be undefined [-Wsequence-point]
   25 |  if(sz[u = find_set(u)] * sz[v = find_set(v)] - 1 == cnt[u][v]){
      |                              ~~^~~~~~~~~~~~~
game.cpp:25:32: warning: operation on 'v' may be undefined [-Wsequence-point]
game.cpp:25:10: warning: operation on 'u' may be undefined [-Wsequence-point]
   25 |  if(sz[u = find_set(u)] * sz[v = find_set(v)] - 1 == cnt[u][v]){
      |        ~~^~~~~~~~~~~~~
game.cpp:25:10: warning: operation on 'u' may be undefined [-Wsequence-point]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...