제출 #1214815

#제출 시각아이디문제언어결과실행 시간메모리
1214815Braabebo10Regions (IOI09_regions)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define ll short #define nl "\n" #define all(v) v.begin(),v.end() #define baraa ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; int main() { baraa ll n, m, q; cin >> n >> m >> q; vector<ll> adj[n + 1], dep(n + 1, 0), tree, in(n + 1), out(n + 1), c(n + 1), col[n + 1]; for (ll i = 1; i <= n; i++) { if (i > 1) { ll x; cin >> x; adj[i].push_back(x); adj[x].push_back(i); } cin >> c[i]; col[c[i]].push_back(i); } function<void(ll, ll)> dfs = [&](ll u, ll p) { tree.push_back(u); in[u] = tree.size() - 1; for (ll v: adj[u]) if (v != p) dfs(v, u); tree.push_back(u); out[u] = tree.size() - 1; }; dfs(1, 0); vector<vector<ll> > ans(m + 1, vector<ll>(m + 1, -1)); ll sz = tree.size(); for (ll i = 1; i <= m; i++) { vector<ll> pref(sz, 0); for (ll u: col[i]) pref[in[u]]++; for (ll j = 1; j < sz; j++)pref[j] += pref[j - 1]; auto get = [&](ll l, ll r) { if (!l)return pref[r]; return pref[r] - pref[l - 1]; }; for (ll j = 1; j <= m; j++) { if (i == j)continue; ans[j][i] = 0; for (ll u: col[j]) ans[j][i] += get(in[u], out[u]); // cout << j << ' ' << i << ' ' << ans[j][i] << nl; } } while (q--) { ll x, y; cin >> x >> y; if (ans[x][y] == -1)cout << col[x].size() * col[y].size() - ans[y][x] << endl; else cout << ans[x][y] << endl; } return 0; }

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

regions.cpp: In lambda function:
regions.cpp:42:28: error: inconsistent types 'short int' and 'int' deduced for lambda return type
   42 |             return pref[r] - pref[l - 1];