제출 #899044

#제출 시각아이디문제언어결과실행 시간메모리
899044josanneo22열대 식물원 (Tropical Garden) (IOI11_garden)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define L(i,j,k) for(int i=j;i<=k;i++) #define R(i,j,k) for(int i=j;i>=k;i--) int N, M, P, Q; constexpr int NN = 1005; vector<pair<int,int>> G[NN]; int who1[NN], who2[NN], pos[NN][105]; void dfs(int u,int f, int trails){ if(trails>=101) return; pos[u][trails]++; if(who1[u]==-1) dfs(f, u, trails + 1); if(f != who1[u]) dfs(who1[u], u, trails + 1); else if(f != who2[u] && who2[u] != -1) dfs(who2[u], u, trails+1); else dfs(f, u, trails+1); } void count_routes(int _N, int _M, int _P, int _R[][2],int _Q, int _G[]){ N=_N; M=_M; P=_P; Q=_Q; //find the number of nodes that end at P L(i,1,N){ who1[u] = who2[u] = -1; mn1[u] = mn2[u] = 1E9; memset(pos[i], 0, sizeof(pos[i])); } L(i, 0, M-1){ int u=_R[i][0], v=_R[i][1]; G[u].push_back(make_pair(v,i)); G[v].push_back(make_pair(u,i)); } L(i, 1, N){ for(auto &v:G[u]){ if(v.second < mn1[u]){ mn2[u] = mn1[u]; mn1[u] = v.second; who2[u] = who1[u]; who1[u] = v.first; } else if(v.second<mn2[u]){ mn2[u] = v.second; who2[u] = v.first; } } } L(i, 1, N) dfs(i); long long ans = 0; L(i, 0, Q - 1){ int u = G[i]; ans += pos[P][u]; } answer(ans); }

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

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:23:8: error: 'u' was not declared in this scope
   23 |   who1[u] = who2[u] = -1;
      |        ^
garden.cpp:24:3: error: 'mn1' was not declared in this scope
   24 |   mn1[u] = mn2[u] = 1E9;
      |   ^~~
garden.cpp:24:12: error: 'mn2' was not declared in this scope
   24 |   mn1[u] = mn2[u] = 1E9;
      |            ^~~
garden.cpp:33:17: error: 'u' was not declared in this scope
   33 |   for(auto &v:G[u]){
      |                 ^
garden.cpp:34:18: error: 'mn1' was not declared in this scope
   34 |    if(v.second < mn1[u]){
      |                  ^~~
garden.cpp:35:5: error: 'mn2' was not declared in this scope
   35 |     mn2[u] = mn1[u];
      |     ^~~
garden.cpp:40:21: error: 'mn2' was not declared in this scope
   40 |    else if(v.second<mn2[u]){
      |                     ^~~
garden.cpp:46:18: error: too few arguments to function 'void dfs(int, int, int)'
   46 |  L(i, 1, N) dfs(i);
      |                  ^
garden.cpp:11:6: note: declared here
   11 | void dfs(int u,int f, int trails){
      |      ^~~
garden.cpp:49:14: error: cannot convert 'std::vector<std::pair<int, int> >' to 'int' in initialization
   49 |   int u = G[i];
      |           ~~~^
      |              |
      |              std::vector<std::pair<int, int> >
garden.cpp:52:2: error: 'answer' was not declared in this scope
   52 |  answer(ans);
      |  ^~~~~~