제출 #1282576

#제출 시각아이디문제언어결과실행 시간메모리
1282576nikaa123Park (JOI17_park)C++20
컴파일 에러
0 ms0 KiB
#include "park.h" #include <bits/stdc++.h> using namespace std; static int visited[1405]; vector <int> leaf; int cnt[1405]; int p[1405]; vector <vector<int>> v(1405); int N; bool check(int node, int pref, vector <int> v) { if (node > N-1 || node <= 0) return false; int a[N]= {0}; for (int i = 1; i <= pref; i++) { a[v[i]] = 1; } for (int i = 0; i < N; i++) { if (visited[i]) a[i] = 1; } a[0] = 1; a[node] = 1; return Ask(0,node,a); } bool check1(int node, int pref, vector <int> v) { if (node > N-1 || node <= 0) return false; int a[N] = {0}; for (int i = 0; i < N; i++) { if (visited[i]) a[i] = 1; } for (int i = 0; i <= v.size()-1; i++) { a[v[i]] = 0; } for (int i = 0; i < pref; i++) { a[v[i]] = 1; } a[0] = 1; a[node] = 1; return Ask(0,node,a); } void Detect(int T, int n) { N = n; int root = 0; visited[root] = 0; stack <int> s; for (int i = 0; i < N; i++) { if (visited[i]) continue; s.push(i); while (!s.empty()) { int node = s.top(); vector <int> nodes; nodes.push_back(-1); for (int j = 0; j < N; j++) { if (!visited[j]) nodes.push_back(j); } int l = 0; int r = nodes.size()-1; int res = -1; while (l <= r) { int mid = (l+r)/2; if (check(node,mid,nodes)) { res = nodes[mid]; r = mid - 1; } else { l = mid + 1; } } if (res != -1) { s.push(res); continue; } l = 0; r = leaf.size()-1; while (l <= r) { int mid = (l+r)/2; if (check1(node,mid,leaf)) { res = leaf[mid]; r = mid - 1; } else { l = mid + 1; } } cnt[res]++; cnt[node]++; if (cnt[res] > 1) { auto it = find(leaf.begin(),leaf.end(),res); leaf.erase(it); } if (cnt[node] == 1) { leaf.push_back(node); } } p[node] = res; visited[node] = 1; s.pop(); } } for (int i = 0; i < N; i++) { // if (p[i] >= N) exit(0); if (p[i] <0 || p[i] >= N) continue; Answer(min(i,p[i]),max(i,p[i])); v[i].push_back(p[i]); v[p[i]].push_back(i); } }

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

park.cpp: In function 'void Detect(int, int)':
park.cpp:94:27: error: 'node' was not declared in this scope
   94 |                         p[node] = res;
      |                           ^~~~
park.cpp:94:35: error: 'res' was not declared in this scope
   94 |                         p[node] = res;
      |                                   ^~~
park.cpp: At global scope:
park.cpp:100:9: error: expected unqualified-id before 'for'
  100 |         for (int i = 0; i < N; i++) {
      |         ^~~
park.cpp:100:25: error: 'i' does not name a type
  100 |         for (int i = 0; i < N; i++) {
      |                         ^
park.cpp:100:32: error: 'i' does not name a type
  100 |         for (int i = 0; i < N; i++) {
      |                                ^
park.cpp:110:1: error: expected declaration before '}' token
  110 | }
      | ^