제출 #753347

#제출 시각아이디문제언어결과실행 시간메모리
753347Dan4LifeMeetings (JOI19_meetings)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) const int mxN = (int)2e3+10; int n, used[mxN]; set<int> S[mxN]; map<array<int,3>,int> M; int query(int a, int b, int c){ if(a>b) swap(a,b); if(b>c) swap(b,c); if(a>b) swap(a,b); if(M.count({a,b,c})) return M[{a,b,c}] return Query(a,b,c); } void mergeSort(vector<int> &v, int a, int b){ if(sz(v)<=1) return; int mid = sz(v)/2; vector<int> w,x; w.clear(), x.clear(); for(int i = 0; i < mid; i++) w.pb(v[i]); for(int i = mid; i < sz(v); i++) x.pb(v[i]); mergeSort(w,a,b), mergeSort(x,a,b); v.clear(); int i = 0, j = 0; while(i<sz(w) and j<sz(x)){ if(query(a,w[i],x[j])==w[i]) v.pb(w[i++]); else v.pb(x[j++]); } while(i<sz(w)) v.pb(w[i++]); while(j<sz(x)) v.pb(x[j++]); } void recur(int a, set<int> SS){ if(SS.empty()) return; auto itr = SS.begin(); int r = rand()%sz(SS); while(r--) itr++; int b = *itr; used[a]=used[b]=1; vector<int> path; path.clear(); set<int> S[n+1]; for(int i = 0; i < n; i++) S[i].clear(); for(auto i : SS){ if(!used[i]){ int x = query(a,b,i); if(x==i) path.pb(i),used[i]=1; else S[x].insert(i); } } mergeSort(path,a,b); if(path.empty()) Bridge(a,b); else Bridge(a,path[0]),Bridge(path.back(),b); for(int i = 0; i < sz(path)-1; i++) Bridge(path[i],path[i+1]); for(auto u : path) recur(u,S[u]); recur(a,S[a]); recur(b,S[b]); } void Solve(int N) { n = N; vector<int> v; for(int i = 1; i < n; i++) S[0].insert(i); recur(0,S[0]); }

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

meetings.cpp: In function 'int query(int, int, int)':
meetings.cpp:16:43: error: expected ';' before 'return'
   16 |     if(M.count({a,b,c})) return M[{a,b,c}]
      |                                           ^
      |                                           ;
   17 |  return Query(a,b,c);
      |  ~~~~~~                                    
meetings.cpp:17:9: error: 'Query' was not declared in this scope; did you mean 'query'?
   17 |  return Query(a,b,c);
      |         ^~~~~
      |         query
meetings.cpp: In function 'void recur(int, std::set<int>)':
meetings.cpp:52:19: error: 'Bridge' was not declared in this scope
   52 |  if(path.empty()) Bridge(a,b);
      |                   ^~~~~~
meetings.cpp:53:7: error: 'Bridge' was not declared in this scope
   53 |  else Bridge(a,path[0]),Bridge(path.back(),b);
      |       ^~~~~~
meetings.cpp:54:38: error: 'Bridge' was not declared in this scope
   54 |  for(int i = 0; i < sz(path)-1; i++) Bridge(path[i],path[i+1]);
      |                                      ^~~~~~