제출 #973830

#제출 시각아이디문제언어결과실행 시간메모리
973830Halym2007Bosses (BOI16_bosses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e2 + 5; #define ll long long #define pb push_back #define sz size() map <int, int> mp[N]; int n, val[N][N], sub[N], vis[N]; vector <int> v[N], p[N]; void solve (int x, int pr) { for (int i : p[x]) { if (i == pr) continue; solve (i, x); sub[x] += sub[i]; } sub[x]++; } int root(int x) { queue <int> q; for (int i = 1; i <= n; ++i) { vis[i] = 0; sub[i] = 0; p[i].clear(); } q.push(x); vis[x] = 1; while (!q.empty()) { int x = q.front(); q.pop(); for (int i : v[x]) { if (vis[i]) continue; p[x].pb (i); vis[i] = 1; q.push(i); } } for (int i = 1; i <= n; ++i) { if (!vis[i]) return -1; } solve (x, -1); int ret = 0; #include <bits/stdc++.h> using namespace std; const int N = 2e2 + 5; #define ll long long #define pb push_back #define sz size() map <int, int> mp[N]; int n, val[N][N], sub[N], vis[N]; vector <int> v[N], p[N]; void solve (int x, int pr) { for (int i : p[x]) { if (i == pr) continue; solve (i, x); sub[x] += sub[i]; } sub[x]++; } int root(int x) { queue <int> q; for (int i = 1; i <= n; ++i) { vis[i] = 0; sub[i] = 0; p[i].clear(); } q.push(x); vis[x] = 1; while (!q.empty()) { int x = q.front(); q.pop(); for (int i : v[x]) { if (vis[i]) continue; p[x].pb (i); vis[i] = 1; q.push(i); } } for (int i = 1; i <= n; ++i) { if (!vis[i]) return -1; } solve (x, -1); int ret = 0; for (int i = 1; i <= n; ++i) { ret += sub[i]; } return ret; } int main () { // freopen ("input.txt", "r", stdin); cin >> n; for (int i = 1; i <= n; ++i) { int k; cin >> k; for (int j = 1; j <= k; ++j) { cin >> val[i][j]; v[val[i][j]].pb (i); } } int jog = 1e9; for (int i = 1; i <= n; ++i) { int jj = root (i); if (~jj) { jog = min (jog, jj); } } cout << jog; }

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

bosses.cpp: In function 'int root(int)':
bosses.cpp:59:28: error: a function-definition is not allowed here before '{' token
   59 | void solve (int x, int pr) {
      |                            ^
bosses.cpp:69:17: error: a function-definition is not allowed here before '{' token
   69 | int root(int x) {
      |                 ^
bosses.cpp:100:13: error: a function-definition is not allowed here before '{' token
  100 | int main () {
      |             ^
bosses.cpp:46:6: warning: unused variable 'ret' [-Wunused-variable]
   46 |  int ret = 0;
      |      ^~~
bosses.cpp:56:5: warning: unused variable 'n' [-Wunused-variable]
   56 | int n, val[N][N], sub[N], vis[N];
      |     ^
bosses.cpp:56:8: warning: unused variable 'val' [-Wunused-variable]
   56 | int n, val[N][N], sub[N], vis[N];
      |        ^~~
bosses.cpp:56:19: warning: unused variable 'sub' [-Wunused-variable]
   56 | int n, val[N][N], sub[N], vis[N];
      |                   ^~~
bosses.cpp:56:27: warning: unused variable 'vis' [-Wunused-variable]
   56 | int n, val[N][N], sub[N], vis[N];
      |                           ^~~
bosses.cpp:119:1: error: expected '}' at end of input
  119 | }
      | ^
bosses.cpp:23:17: note: to match this '{'
   23 | int root(int x) {
      |                 ^
bosses.cpp:24:14: warning: control reaches end of non-void function [-Wreturn-type]
   24 |  queue <int> q;
      |              ^