제출 #1210179

#제출 시각아이디문제언어결과실행 시간메모리
1210179bakhtiyarnVinjete (COI22_vinjete)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5+5; const int N2 = 1e5+1; vector<array<int, 3>> g[N2]; int ans[N2]; int n, M; int nxt = 1; map<int, int> L, R, sg, lz; void push(int u, int l, int r, int U, map<int, int> &usedsg, map<int, int> &usedlz){ if(lz[u]) { if(usedsg.find(u) == usedsg.end()) usedsg[u] = sg[u]; sg[u] = r-l+1; } if(l != r){ if(!L[u]) L[u] = ++next; if(!R[u]) R[u] = ++next; if(L.find(u) != L.end()) { if(usedlz.find(L[u]) == usedlz.end()) usedlz[L[u]] = lz[L[u]]; lz[L[u]] += lz[u]; } if(R.find(u) != R.end()) { if(usedlz.find(R[u]) == usedlz.end()) usedlz[R[u]] = lz[R[u]]; lz[R[u]] += lz[u]; } } } void update(int u, int l, int r, int x, int y, int U, map<int, int> &usedsg, map<int, int> &usedlz){ push(u, l, r, U, usedsg, usedlz); if(y < l or x > r) return; if(x <= l and y >= r){ if(usedlz.find(u) == usedlz.end()) usedlz[u] = lz[u]; lz[u]++; push(u, l, r, U, usedsg, usedlz); return; } /// int m = (l+r)/2; if(y < l or x > m) { if(L.find(u) != L.end()) push(L[u], l, m, U, usedsg, usedlz); } else { if(L.find(u) == L.end()) { L[u] = ++nxt; push(u, l, r, U, usedsg, usedlz); } update(L[u], l, m, x, y, U, usedsg, usedlz); } if(y < m+1 or x > r) { if(R.find(u) != R.end()) push(R[u], m+1, r, U, usedsg, usedlz); } else { if(R.find(u) == R.end()) { R[u] = ++nxt; push(u, l, r, U, usedsg, usedlz); } update(R[u], m+1, r, x, y, U, usedsg, usedlz); } /// if(usedsg.find(u) == usedsg.end()) usedsg[u] = sg[u]; int sol = 0, sag = 0; if(L.find(u) != L.end()) sol = L[u]; if(R.find(u) != R.end()) sag = R[u]; sg[u] = sg[sol] + sg[sag]; } void dfs(int u, int p, int li, int ri){ map<int, int> usedsg, usedlz; update(1, 1, M, li, ri, u, usedsg, usedlz); ans[u] = sg[1]; for(auto [to, lj, rj]: g[u]){ if(to == p) continue; dfs(to, u, lj, rj); } for(auto [node, ans]: usedsg) sg[node] = ans; for(auto [node, ans]: usedlz) lz[node] = ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> M; for(int i=1; i<n; i++){ int x, y, li, ri; cin >> x >> y >> li >> ri; g[x].push_back({y, li, ri}); g[y].push_back({x, li, ri}); } dfs(1, -1, 0, 0); for(int i=2; i<=n; i++) cout << ans[i] << '\n'; }

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

Main.cpp: In function 'void push(long long int, long long int, long long int, long long int, std::map<long long int, long long int>&, std::map<long long int, long long int>&)':
Main.cpp:22:24: error: no pre-increment operator for type
   22 |     if(!L[u]) L[u] = ++next;
      |                        ^~~~
Main.cpp:23:24: error: no pre-increment operator for type
   23 |     if(!R[u]) R[u] = ++next;
      |                        ^~~~