제출 #433525

#제출 시각아이디문제언어결과실행 시간메모리
433525JUANDI321Split the Attractions (IOI19_split)C++17
컴파일 에러
0 ms0 KiB
#include "split.h" #include <vector> using namespace std; vector<vector<int>> g; vector<int> res; int aa, bb, cc; void dfs(int node, int ant) { if(a>0) { res[node]=1; a--; } else if(b>0) { res[node]=2; b--; } else { res[node]=3; c--; } for(int y : g[node]) { if(y!=ant) { dfs(y, node); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { aa = a; bb = b; cc = c; //vector<int> res; for(int i = 0; i<p.size(); i++) { g[p[i]].push_back(q[i]); g[q[i]].push_back(p[i]); } int node =0; for(int i = 0; i<n; i++) { if(g[i].size()==1) { node = i; break; } } dfs(node, -1); return res; }

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

split.cpp: In function 'void dfs(int, int)':
split.cpp:11:5: error: 'a' was not declared in this scope; did you mean 'aa'?
   11 |  if(a>0)
      |     ^
      |     aa
split.cpp:16:10: error: 'b' was not declared in this scope; did you mean 'bb'?
   16 |  else if(b>0)
      |          ^
      |          bb
split.cpp:24:3: error: 'c' was not declared in this scope; did you mean 'cc'?
   24 |   c--;
      |   ^
      |   cc
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for(int i = 0; i<p.size(); i++)
      |                 ~^~~~~~~~~