제출 #920601

#제출 시각아이디문제언어결과실행 시간메모리
920601DON_FEaster Eggs (info1cup17_eastereggs)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; using ll = long long; #define F first #define S second vector < vector < int > > g; set < int > cur, sp; vector < int > all, vis; ll p; void dfs(int u){ if ((int) sp.size() == p){ return; } vis[u] = 1; all.push_back(u); if (cur.count(u)){ sp.insert(u); } for (auto &i : g[u]){ if (!vis[i]) dfs(i); } } int findEgg (int n, vector < pair < int, int > > z){ for (int i = 1; i <= n; ++i){ cur.insert(i); } g = vector < vector < int > > (n + 1); for (int i = 0; i < n - 1; ++i){ g[z[i].F].push_back(z[i].S); } while (cur.size() != 1){ p = cur.size() / 2; for (int i = 1; i <= n; ++i){ vis = vector < int > (n + 1); dfs(i); if ((int) sp.size() == p){ break; } sp.clear(); all.clear(); } if (sp.size() != p)return -1; ll tmp = query(all); if (tmp){ cur.clear(); for (auto &i : sp){ cur.insert(i); } }else{ for (auto &i : sp){ cur.erase(i); } } sp.clear(); all.clear(); } return *cur.begin();

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

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:48:23: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   48 |         if (sp.size() != p)return -1;
      |             ~~~~~~~~~~^~~~
eastereggs.cpp:63:24: error: expected '}' at end of input
   63 |     return *cur.begin();
      |                        ^
eastereggs.cpp:29:52: note: to match this '{'
   29 | int findEgg (int n, vector < pair < int, int > > z){
      |                                                    ^