제출 #464805

#제출 시각아이디문제언어결과실행 시간메모리
464805okaragulEaster Eggs (info1cup17_eastereggs)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector<vector<int>> g; vector<int> ord; int dfs(int v, int p){ ord.push_back(v); for(auto &ch:g[v]) if(ch!=p) dfs(ch, v); } int findEgg (int N, vector < pair < int, int > > bridges) { g.assign(N, vector<int>()); ord.clear(); for(int i = 1; i < N; i++){ int &[a, b]=bridges[i-1]; g[a-1].push_back(b-1); g[b-1].push_back(a-1); } dfs(0, -1); int l=1, r=n; while(l<r){ int mid=(l+r)/2; vector<int> tmp; for(int i = 0; i < mid; i++) tmp.push_back(ord[i]); if(!query(tmp)) l=mid+1; else r=mid; } return l; }

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

eastereggs.cpp: In function 'int dfs(int, int)':
eastereggs.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:17:14: error: structured binding declaration cannot have type 'int'
   17 |         int &[a, b]=bridges[i-1];
      |              ^~~~~~
eastereggs.cpp:17:14: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
eastereggs.cpp:22:16: error: 'n' was not declared in this scope
   22 |     int l=1, r=n;
      |                ^