제출 #1357978

#제출 시각아이디문제언어결과실행 시간메모리
1357978mahribanWind Turbines (EGOI25_windturbines)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int> E[1000009];
int vis[1000009];
int h[1000009];
int main(){
    int n, m, q;
    vector<pair<int, pair<int, int>>> p;
    cin >> n >> m >> q;
    for (int a, b, c, i = 1; i <= m; i ++){
        cin >> a >> b >> c;
        p.push_back({c, {a, b}});
    }
    int x, y;
    sort(p.begin(), p.end());
    while (q --){
        long long ans = 0;
        cin >> x >> y;
        for (int i = x; i <= y; i ++)vis[i] = 1;
        int ind = 1;
        for (auto i : p){
            if (vis[i.second.first] == 1 && vis[i.second.second] == 1)continue;
            if (vis[i.second.first] == 1 || vis[i.second.second] == 1){
                ans += i.first;
                if (vis[i.second.first] == 0)vis[i.second.first] = 1;
                if (vis[i.second.second] == 0)vis[i.second.second] = 1;
                if (vis[i.second.first] == 1 && vis[i.second.second] == 2){
                    for (auto j : E[h[i.second.second]]){
                        vis[j] = 1;
                        h[j] = 0;
                    }
                }
                else{
                    for (auto j : E[h[i.second.first]]){
                        vis[j] = 1;
                        h[j] = 0;
                    }
                }
            }
            else {
                ans += i.first;
                if (!vis[i.second.first] && !vis[i.second.second]){
                    E[ind].push_back(i.second.first);
                    E[ind].push_back(i.second.second);
                    vis[i.second.first] = 2;
                    vis[i.second.second] = 2;
                    h[i.second.first] = ind;
                    h[i.second.second] = ind;
                    ind ++;
                }
                else if (vis[i.second.first] == 2 && vis[i.second.second] == 2){
                    if (h[i.second.first] == h[i.second.second])continue;
                    int a = h[i.second.first];
                    int b = h[i.second.second];
                    if (E[a].size() < E[b].size()){
                        for (auto j : E[a]){
                            E[b].push_back(j);
                            h[j] = h[j] = b;
                        }
                    }
                    if (E[a].size() >= E[b].size()){
                        for (auto j : E[b]){
                            E[a].push_back(j);
                            h[j] = h[j] = a;
                        }
                    }
                }
                else if (vis[i.second.first] == 2){
                    E[h[i.second.first]].push_back(i.second.second);
                    h[i.second.second] = h[i.second.first];
                    vis[i.second.second] = 2;
                }
                else if (vis[i.second.second] == 2){
                    h[i.second.first] = h[i.second.second];
                    vis[i.second.first] = 2;
                }
        for (int i = 0; i < 1000009; i ++){
            vis[i] = h[i] = 0;
            E[i].clear();
        }
        cout << ans << endl;
    }
}

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

Main.cpp: In function 'int main()':
Main.cpp:83:2: error: expected '}' at end of input
   83 | }
      |  ^
Main.cpp:16:17: note: to match this '{'
   16 |     while (q --){
      |                 ^
Main.cpp:83:2: error: expected '}' at end of input
   83 | }
      |  ^
Main.cpp:6:11: note: to match this '{'
    6 | int main(){
      |           ^