답안 #244635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244635 2020-07-04T13:14:30 Z kimbj0709 Toll (BOI17_toll) C++14
8 / 100
3000 ms 8696 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 50050
#define f first
#define s second
int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int k,no_of_vertex,no_of_edge,no_of_query;
    int input1,input2,input3;
    cin >> k >> no_of_vertex >> no_of_edge >> no_of_query;
    vector<vector<pair<int,int> > > adj(maxn);
    for(int i=0;i<no_of_edge;i++){
        cin >> input1 >> input2 >> input3;
        adj[input1].push_back({input2,input3});
    }
    for(int i=0;i<no_of_query;i++){
        cin >> input1 >> input2;
        vector<int> dist(maxn,INT_MAX);
        priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q1;
        dist[input1] = 0;
        q1.push({0,input1});
        while(q1.size()!=0){
            pair<int,int> a = q1.top();
            q1.pop();
            for(auto j:adj[a.s]){
                if(dist[j.f]>a.f+j.s){
                    dist[j.f] = a.f+j.s;
                    q1.push({dist[j.f],j.f});
                }
            }
        }
        if(dist[input2]==INT_MAX){
            cout << -1 << "\n";
        }
        else{
            cout << dist[input2] << "\n";
        }
    }

}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 3664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3072 ms 4488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1920 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 6 ms 2048 KB Output is correct
5 Correct 6 ms 1920 KB Output is correct
6 Correct 8 ms 1920 KB Output is correct
7 Correct 12 ms 2040 KB Output is correct
8 Correct 20 ms 2176 KB Output is correct
9 Correct 16 ms 2048 KB Output is correct
10 Correct 31 ms 4352 KB Output is correct
11 Correct 402 ms 6012 KB Output is correct
12 Correct 399 ms 8056 KB Output is correct
13 Correct 460 ms 8696 KB Output is correct
14 Correct 375 ms 6904 KB Output is correct
15 Correct 248 ms 5112 KB Output is correct
16 Correct 235 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1920 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 6 ms 2048 KB Output is correct
5 Correct 6 ms 1920 KB Output is correct
6 Correct 8 ms 1920 KB Output is correct
7 Correct 12 ms 2040 KB Output is correct
8 Correct 20 ms 2176 KB Output is correct
9 Correct 16 ms 2048 KB Output is correct
10 Correct 31 ms 4352 KB Output is correct
11 Correct 402 ms 6012 KB Output is correct
12 Correct 399 ms 8056 KB Output is correct
13 Correct 460 ms 8696 KB Output is correct
14 Correct 375 ms 6904 KB Output is correct
15 Correct 248 ms 5112 KB Output is correct
16 Correct 235 ms 5112 KB Output is correct
17 Execution timed out 3079 ms 6128 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 3664 KB Time limit exceeded
2 Halted 0 ms 0 KB -