Submission #672089

#TimeUsernameProblemLanguageResultExecution timeMemory
672089tbzard드문 곤충 (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void move_inside(int i); void move_outside(int i); int press_button(); int p[2222]; bool asked[2222][2222]; int root(int a){ return p[a] == a?a:(p[a]=root(p[a])); } void merge(int a, int b, int n){ a = root(a), b = root(b); if(a != b){ p[a] = b; sz[b] += sz[a]; for(int i=1;i<=n;i++){ asked[b][i] |= asked[a][i]; asked[i][b] |= asked[i][a]; } } } int min_cardinality(int n){ for(int i=1;i<=n;i++) p[i] = i, sz[i] = 1; for(int i=1;i<=n;i++) asked[i][i] = 1; set<int> cur; for(int i=1;i<=n;i++) cur.insert(i); int ans = 1e9; while(!cur.empty()){ int u = *cur.begin(); cur.erase(cur.begin()); move_inside(u-1); for(int i=1;i<=n;i++){ int ru = root(u), rv = root(i); if(asked[ru][rv]) continue; if(sz[ru] >= ans) break; move_inside(i-1); int r = press_button(); if(r == 2){ asked[ru][rv] = 1; asked[rv][ru] = 1; merge(u, i, n); cur.erase(cur.find(i)); } else{ asked[ru][rv] = 1; asked[rv][ru] = 1; } move_outside(i-1); } move_outside(u-1); ans = min(ans, sz[root(u)]); } return ans; }

Compilation message (stderr)

insects.cpp: In function 'void merge(int, int, int)':
insects.cpp:16:9: error: 'sz' was not declared in this scope
   16 |         sz[b] += sz[a];
      |         ^~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:24:37: error: 'sz' was not declared in this scope
   24 |     for(int i=1;i<=n;i++) p[i] = i, sz[i] = 1;
      |                                     ^~
insects.cpp:38:16: error: 'sz' was not declared in this scope
   38 |             if(sz[ru] >= ans) break;
      |                ^~
insects.cpp:55:24: error: 'sz' was not declared in this scope
   55 |         ans = min(ans, sz[root(u)]);
      |                        ^~