제출 #140278

#제출 시각아이디문제언어결과실행 시간메모리
140278bazsi700통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "highway.h" using namespace std; #define MOD 1000000007 #define ll long long int #define vi vector<int> #define vii vector< vector<int> > #define PI 3.1415926535897932384626433832795 #define INF 9223372036854775807LL #define hashA 1257958787 #define hashB 1539500609 #define endl "\n" vector<vector<pair<int,int> > > graph (91000,vector<pair<int,int> >()); bool excluded[91000]; bool inset[91000]; bool was[91000]; bool hasspec[91000]; int siz[91000]; int par[91000]; int n,spec,dist; void dfs(int v) { was[v] = true; siz[v] = 1; for(auto ed : graph[v]) { if(!was[ed.first]) { par[ed.first] = v; dfs(ed.first); if(hasspec[ed.first]) { hasspec[v] = true; } siz[v]+= siz[ed.first]; } } if(spec == v) { hasspec[v] = true; } } void putinset(int v) { was[v] = inset[v] = true; for(auto ed : graph[v]) { if(!was[ed.first]) { putinset(ed.first); } } } void findset() { memset(was,false,sizeof(was)); memset(inset,false,sizeof(inset)); int sta; int cnt = 0; for(int i = 1; i <= n; i++) { if(!excluded[i]) { sta = i; cnt++; } } par[sta] = -1; dfs(sta); int big = sta; while(big != -1) { sta = big; for(auto ed : graph[sta]) { if(siz[ed.first] > cnt/2) { big = ed.first; if(!hasspec[ed.first]) { hasspec[ed.first] = true; } else { hasspec[sta] = false; } siz[sta] = cnt-siz[ed.first]; siz[ed.first] = cnt; break; } } } vector<pair<int,int> > nodes; for(auto ed : graph[sta]) { nodes.push_back({siz[ed.first],ed.first}); } sort(nodes.begin(),nodes.end()); int currsiz = 1; inset[sta] = true; was[sta] = true; memset(was,false,sizeof(was)); bool isspec = false; for(auto el : nodes) { if(abs(cnt/2-currsiz+el.first) <= abs(cnt/2-currsiz)) { currsiz+= el.first; putinset(el.second); if(hasspec[el.second]) { isspec = true; } } else { break; } } if(isspec) { int cn = 0; for(int i = 1; i <= n; i++) { if(!excluded[i]) { inset[i] = !inset[i]; if(inset[i]) { cn++; } } } if(cnt-cn > 1) { inset[sta] = true; } } vector<int> toask(n-1,0); for(int i = 1; i <= n; i++) { if(inset[i] && i != spec) { for(auto ed : graph[i]) { toask[ed.second] = 1; } } } int x = ask(toask); if(x > dist) { for(int i = 1; i <= n; i++) { if(!inset[i] && !excluded[i]) { excluded[i] = true; cnt--; } } spec = sta; } else { for(int i = 1; i <= n; i++) { if(inset[i]) { excluded[i] = true; cnt--; } } cnt++; inset[sta] = true; } return cnt; } void find_pair(int N, vector<int> u, vector<int> v, int A, int B) { n = N; for(int i = 0; i < n-1; i++) { graph[u[i]].push_back({v[i],i}); graph[v[i]].push_back({u[i],i}); } vector<int> toask(n-1,0); dist = ask(toask); spec = -1; while(findset() > 1) {} answer(spec,spec); }

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

highway.cpp: In function 'void findset()':
highway.cpp:143:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
  return cnt;
         ^~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:155:18: error: invalid operands of types 'void' and 'int' to binary 'operator>'
  while(findset() > 1) {}
        ~~~~~~~~~~^~~