제출 #840335

#제출 시각아이디문제언어결과실행 시간메모리
840335mat_jurRegions (IOI09_regions)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << ", " << p.second << ")"; return o;} auto operator<<(auto &o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto e : x) o<<e<<", "; return o<<"}";} #define debug(X) cerr << "["#X"]: " << X << '\n'; #else #define debug(X) ; #endif #define ll long long #define all(v) (v).begin(), (v).end() #define FOR(i,l,r) for(int i=(l);i<=(r);++i) #define ROF(i,r,l) for(int i=(r);i>=(l);--i) #define REP(i,n) FOR(i,0,(n)-1) #define ssize(x) int(x.size()) #define fi first #define se second #define eb emplace_back int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, r, q; cin >> n >> r >> q; vector<int> h(n); cin >> h[0]; h[0]--; vector G(n, vector(0, 0)); FOR(i, 1, n-1) { int p; cin >> p >> h[i]; p--; h[i]--; G[p].eb(i); G[i].eb(p); } auto merge = [&](vector<int> &a, vector<int> &b) { REP(i, r) a[i] += b[i]; return; }; vector ans(r, vector(r, 0)); function<vector<int>(int, int)> dfs = [&](int v, int p) { vector<int> cnt(r); for(auto w : G[v]) { if (w == p) continue; vector<int> b = dfs(w, v); merge(cnt, b); } REP(i, r) ans[h[v]][i] += cnt[i]; cnt[h[v]]++; return cnt; }; dfs(0, -1); REP(i, q) { int r1, r2; cin >> r1 >> r2; r1--; r2--; cout << ans[r1][r2] << '\n'; cout.flush(); } return 0; }

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

regions.cpp: In function 'int main()':
regions.cpp:30:9: error: missing template arguments before 'G'
   30 |  vector G(n, vector(0, 0));
      |         ^
regions.cpp:36:3: error: 'G' was not declared in this scope
   36 |   G[p].eb(i);
      |   ^
regions.cpp:43:9: error: missing template arguments before 'ans'
   43 |  vector ans(r, vector(r, 0));
      |         ^~~
regions.cpp: In lambda function:
regions.cpp:46:16: error: 'G' was not declared in this scope
   46 |   for(auto w : G[v]) {
      |                ^
regions.cpp:51:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |   REP(i, r) ans[h[v]][i] += cnt[i];
      |             ^~~
      |             abs
regions.cpp: In function 'int main()':
regions.cpp:60:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   60 |   cout << ans[r1][r2] << '\n';
      |           ^~~
      |           abs