답안 #840886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840886 2023-08-31T20:10:46 Z Mohmad_Zaid 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
// #include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W)
{
    int n=N;
    set<ll>dis;
    vector<vector<pair<int,int>>g(n,vector<pair<int,int>>());
    for(int i=0;i<n;i++){
        g[U[i]].pb({V[i],W[i]});
        g[V[i]].pb({U[i],W[i]});
    }
    queue<pair<pair<int,int>,ll>>q;
    pair<pair<int,int>,ll>one={{X,X},0},two={{Y,Y},0};
    q.push(one);
    q.push(two);
    while(!q.empty()){
        int p=q.front().first.first;
        int v=q.front().first.second;
        ll cur=q.front().second;
        q.pop();
        for(auto i:g[v]){
            if(i.first==p)continue;
            if(cur+i.second>K)continue;
            dis.insert(cur+i.second);
            pair<pair<int,int>,ll>temp={{v,i.first},i.second+cur};
            q.push(temp);
        }
    }
    int ans=0;
    for(auto i:dis){
        if(i>K)break;
        K-=i;ans++;
    }

    return ans+2;
}
 

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:11:60: error: template argument 1 is invalid
   11 |     vector<vector<pair<int,int>>g(n,vector<pair<int,int>>());
      |                                                            ^
closing.cpp:11:60: error: template argument 2 is invalid
closing.cpp:13:9: error: 'g' was not declared in this scope
   13 |         g[U[i]].pb({V[i],W[i]});
      |         ^
closing.cpp:25:20: error: 'g' was not declared in this scope
   25 |         for(auto i:g[v]){
      |                    ^
closing.cpp:29:65: error: could not convert '{{v, <expression error>}, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<std::pair<int, int>, long long int>'
   29 |             pair<pair<int,int>,ll>temp={{v,i.first},i.second+cur};
      |                                                                 ^
      |                                                                 |
      |                                                                 <brace-enclosed initializer list>