제출 #1061243

#제출 시각아이디문제언어결과실행 시간메모리
1061243thinknoexitReconstruction Project (JOI22_reconstruction)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; struct Edge { int u, v, w; bool operator < (const Edge& o) const { return w < o.w; } } e[100100], e2[100100]; int p[505]; int fr(int i) { return p[i] == i ? i : p[i] = fr(p[i]); } int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1;i <= m;i++) { cin >> e[i].u >> e[i].v >> e[i].w; } sort(e + 1, e + 1 + m); while (q--) { int x; cin >> x; for (int i = 1;i <= m;i++) { e2[i].u = e[i].u; e2[i].v = e[i].v; e2[i].w = abs(e[i].w - x); } for (int i = 1;i <= n;i++) p[i] = i; sort(e2 + 1, e2 + 1 + m); ll ans = 0; for (int i = 1;i <= m;i++) { int pu = fr(e2[i].u), pv = fr(e2[i].v); if (pu == pv) continue; ans += e2[i].w; p[pu] = pv; } cout << ans << '\n'; } return 0; }

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

reconstruction.cpp: In function 'int main()':
reconstruction.cpp:22:12: error: 'q' was not declared in this scope
   22 |     while (q--) {
      |            ^