답안 #522794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522794 2022-02-05T21:46:06 Z Deepesson 꿈 (IOI13_dreaming) C++17
47 / 100
394 ms 13264 KB
#include <bits/stdc++.h>
#include "dreaming.h"
#define MAX 105000
typedef std::pair<int,int> pii;
std::vector<pii> con[MAX];
bool foi[MAX];
int visitou[MAX]={};
int turno=42;
int mais_distante(int x){
    std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue;
    queue.push({0,x});
    int last=0;
    ++turno;
    while(queue.size()){
        auto __ = queue.top();
        queue.pop();
        if(visitou[__.second]==turno)continue;
        visitou[__.second]=turno;
        last=__.second;
        for(auto&x:con[__.second])queue.push({__.first+x.second,x.first});
    }
    return last;
}
int maior_distancia(int x){
    std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue;
    queue.push({0,x});
    int last=0;
    ++turno;
    while(queue.size()){
        auto __ = queue.top();
        queue.pop();
        if(visitou[__.second]==turno)continue;
        visitou[__.second]=turno;
        last=__.first;
        for(auto&x:con[__.second])queue.push({__.first+x.second,x.first});
    }
    return last;
}
std::vector<int> marcar(int x){
    std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue;
    queue.push({0,x});
    std::vector<int> v;
    ++turno;
    while(queue.size()){
        auto __ = queue.top();
        queue.pop();
        if(visitou[__.second]==turno)continue;
        visitou[__.second]=turno;
        v.push_back(__.second);
        foi[__.second]=true;
        for(auto&x:con[__.second])queue.push({__.first+x.second,x.first});
    }
    return v;
}
int maiordist[MAX]={};
int meio(int x){
    int ponta1 = mais_distante(x);
    int ponta2 = mais_distante(ponta1);
    std::vector<int> checar;
    {
        std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue;
        queue.push({0,ponta1});
        bool visitou[MAX]={};
        while(queue.size()){
            auto __ = queue.top();
            queue.pop();
            if(visitou[__.second])continue;
            visitou[__.second]=true;
            checar.push_back(__.second);
            maiordist[__.second]=__.first;
            for(auto&x:con[__.second])queue.push({__.first+x.second,x.first});
        }
    }
    {
        std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue;
        queue.push({0,ponta2});
        bool visitou[MAX]={};
        while(queue.size()){
            auto __ = queue.top();
            queue.pop();
            if(visitou[__.second])continue;
            visitou[__.second]=true;
            maiordist[__.second]=std::max(maiordist[__.second],__.first);
            for(auto&x:con[__.second])queue.push({__.first+x.second,x.first});
        }
    }
    int best=-1;
    int val=1e9+7;
    for(auto&x:checar){
        if(maiordist[x]<val){
            val=maiordist[x];
            best=x;
        }
    }
    return best;
}
int travelTime(int N,int M,int L,int A[],int B[],int T[]){
    for(int i=0;i!=M;++i){
        con[A[i]].push_back({B[i],T[i]});
        con[B[i]].push_back({A[i],T[i]});
    }
    std::vector<std::vector<int>> vec;
    for(int i=0;i!=N;++i){
        if(foi[i])continue;
        vec.push_back(marcar(i));
    }
    std::vector<int> meios;
    for(auto&x:vec){
        meios.push_back(meio(x[0]));
    }
    for(int i=1;i!=meios.size();++i){
        con[meios[i]].push_back({meios[0],L});
        con[meios[0]].push_back({meios[i],L});
    }
    return maior_distancia(mais_distante(0));
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:111:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |     for(int i=1;i!=meios.size();++i){
      |                 ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 9960 KB Output is correct
2 Correct 83 ms 10064 KB Output is correct
3 Correct 63 ms 7440 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 10 ms 3532 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 2 ms 2892 KB Output is correct
8 Correct 48 ms 5828 KB Output is correct
9 Correct 52 ms 6852 KB Output is correct
10 Correct 2 ms 2904 KB Output is correct
11 Correct 79 ms 8260 KB Output is correct
12 Correct 81 ms 9152 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2876 KB Output is correct
2 Correct 2 ms 2892 KB Output is correct
3 Correct 2 ms 2892 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2892 KB Output is correct
6 Correct 2 ms 2896 KB Output is correct
7 Correct 3 ms 2896 KB Output is correct
8 Correct 3 ms 2888 KB Output is correct
9 Correct 3 ms 2892 KB Output is correct
10 Correct 2 ms 2892 KB Output is correct
11 Correct 2 ms 2892 KB Output is correct
12 Correct 2 ms 2892 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 2 ms 2892 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 2 ms 2892 KB Output is correct
17 Correct 2 ms 2896 KB Output is correct
18 Correct 2 ms 2892 KB Output is correct
19 Correct 2 ms 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2756 KB Output is correct
22 Correct 2 ms 2892 KB Output is correct
23 Correct 2 ms 2892 KB Output is correct
24 Correct 2 ms 2896 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 9960 KB Output is correct
2 Correct 83 ms 10064 KB Output is correct
3 Correct 63 ms 7440 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 10 ms 3532 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 2 ms 2892 KB Output is correct
8 Correct 48 ms 5828 KB Output is correct
9 Correct 52 ms 6852 KB Output is correct
10 Correct 2 ms 2904 KB Output is correct
11 Correct 79 ms 8260 KB Output is correct
12 Correct 81 ms 9152 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 2 ms 2876 KB Output is correct
15 Correct 2 ms 2892 KB Output is correct
16 Correct 2 ms 2892 KB Output is correct
17 Correct 2 ms 2892 KB Output is correct
18 Correct 2 ms 2892 KB Output is correct
19 Correct 2 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2888 KB Output is correct
22 Correct 3 ms 2892 KB Output is correct
23 Correct 2 ms 2892 KB Output is correct
24 Correct 2 ms 2892 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 2 ms 2892 KB Output is correct
27 Correct 2 ms 2892 KB Output is correct
28 Correct 2 ms 2764 KB Output is correct
29 Correct 2 ms 2892 KB Output is correct
30 Correct 2 ms 2896 KB Output is correct
31 Correct 2 ms 2892 KB Output is correct
32 Correct 2 ms 2892 KB Output is correct
33 Correct 2 ms 2892 KB Output is correct
34 Correct 2 ms 2756 KB Output is correct
35 Correct 2 ms 2892 KB Output is correct
36 Correct 2 ms 2892 KB Output is correct
37 Correct 2 ms 2896 KB Output is correct
38 Correct 2 ms 2892 KB Output is correct
39 Correct 75 ms 9868 KB Output is correct
40 Correct 75 ms 9872 KB Output is correct
41 Correct 50 ms 7444 KB Output is correct
42 Correct 12 ms 3932 KB Output is correct
43 Correct 2 ms 2892 KB Output is correct
44 Correct 2 ms 2892 KB Output is correct
45 Correct 2 ms 2892 KB Output is correct
46 Correct 2 ms 2892 KB Output is correct
47 Correct 2 ms 2896 KB Output is correct
48 Correct 2 ms 2892 KB Output is correct
49 Correct 2 ms 2892 KB Output is correct
50 Correct 2 ms 2892 KB Output is correct
51 Correct 2 ms 2896 KB Output is correct
52 Correct 2 ms 2892 KB Output is correct
53 Correct 2 ms 2892 KB Output is correct
54 Correct 3 ms 2892 KB Output is correct
55 Correct 2 ms 2892 KB Output is correct
56 Correct 2 ms 2892 KB Output is correct
57 Correct 215 ms 11588 KB Output is correct
58 Correct 219 ms 11072 KB Output is correct
59 Correct 210 ms 11268 KB Output is correct
60 Correct 185 ms 10948 KB Output is correct
61 Correct 232 ms 11380 KB Output is correct
62 Correct 202 ms 11140 KB Output is correct
63 Correct 284 ms 11420 KB Output is correct
64 Correct 250 ms 11464 KB Output is correct
65 Correct 251 ms 11672 KB Output is correct
66 Correct 327 ms 11728 KB Output is correct
67 Correct 191 ms 11212 KB Output is correct
68 Correct 184 ms 11280 KB Output is correct
69 Correct 185 ms 11336 KB Output is correct
70 Correct 194 ms 11184 KB Output is correct
71 Correct 1 ms 2764 KB Output is correct
72 Correct 5 ms 3020 KB Output is correct
73 Correct 6 ms 3148 KB Output is correct
74 Correct 6 ms 3156 KB Output is correct
75 Correct 6 ms 3020 KB Output is correct
76 Correct 6 ms 3164 KB Output is correct
77 Correct 7 ms 3140 KB Output is correct
78 Correct 6 ms 3020 KB Output is correct
79 Correct 5 ms 3148 KB Output is correct
80 Correct 195 ms 11196 KB Output is correct
81 Correct 184 ms 11196 KB Output is correct
82 Correct 208 ms 11368 KB Output is correct
83 Correct 215 ms 11452 KB Output is correct
84 Correct 5 ms 3020 KB Output is correct
85 Correct 4 ms 3020 KB Output is correct
86 Correct 5 ms 3020 KB Output is correct
87 Correct 6 ms 3052 KB Output is correct
88 Correct 5 ms 3020 KB Output is correct
89 Correct 5 ms 3020 KB Output is correct
90 Correct 5 ms 3020 KB Output is correct
91 Correct 6 ms 3148 KB Output is correct
92 Correct 6 ms 3020 KB Output is correct
93 Correct 5 ms 3076 KB Output is correct
94 Correct 2 ms 2892 KB Output is correct
95 Correct 2 ms 2892 KB Output is correct
96 Correct 2 ms 2892 KB Output is correct
97 Correct 2 ms 2892 KB Output is correct
98 Correct 2 ms 2772 KB Output is correct
99 Correct 2 ms 2892 KB Output is correct
100 Correct 2 ms 2892 KB Output is correct
101 Correct 2 ms 2764 KB Output is correct
102 Correct 2 ms 2896 KB Output is correct
103 Correct 2 ms 2888 KB Output is correct
104 Correct 10 ms 3532 KB Output is correct
105 Correct 18 ms 4676 KB Output is correct
106 Correct 2 ms 2892 KB Output is correct
107 Correct 36 ms 5768 KB Output is correct
108 Correct 47 ms 6736 KB Output is correct
109 Correct 2 ms 2892 KB Output is correct
110 Correct 68 ms 8256 KB Output is correct
111 Correct 87 ms 9168 KB Output is correct
112 Correct 2 ms 2892 KB Output is correct
113 Correct 111 ms 10784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 394 ms 13264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2876 KB Output is correct
2 Correct 2 ms 2892 KB Output is correct
3 Correct 2 ms 2892 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2892 KB Output is correct
6 Correct 2 ms 2896 KB Output is correct
7 Correct 3 ms 2896 KB Output is correct
8 Correct 3 ms 2888 KB Output is correct
9 Correct 3 ms 2892 KB Output is correct
10 Correct 2 ms 2892 KB Output is correct
11 Correct 2 ms 2892 KB Output is correct
12 Correct 2 ms 2892 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 2 ms 2892 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 2 ms 2892 KB Output is correct
17 Correct 2 ms 2896 KB Output is correct
18 Correct 2 ms 2892 KB Output is correct
19 Correct 2 ms 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2756 KB Output is correct
22 Correct 2 ms 2892 KB Output is correct
23 Correct 2 ms 2892 KB Output is correct
24 Correct 2 ms 2896 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 4 ms 2892 KB Output is correct
27 Correct 6 ms 3020 KB Output is correct
28 Correct 7 ms 3148 KB Output is correct
29 Incorrect 4 ms 2944 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 9960 KB Output is correct
2 Correct 83 ms 10064 KB Output is correct
3 Correct 63 ms 7440 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 10 ms 3532 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 2 ms 2892 KB Output is correct
8 Correct 48 ms 5828 KB Output is correct
9 Correct 52 ms 6852 KB Output is correct
10 Correct 2 ms 2904 KB Output is correct
11 Correct 79 ms 8260 KB Output is correct
12 Correct 81 ms 9152 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 2 ms 2876 KB Output is correct
15 Correct 2 ms 2892 KB Output is correct
16 Correct 2 ms 2892 KB Output is correct
17 Correct 2 ms 2892 KB Output is correct
18 Correct 2 ms 2892 KB Output is correct
19 Correct 2 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2888 KB Output is correct
22 Correct 3 ms 2892 KB Output is correct
23 Correct 2 ms 2892 KB Output is correct
24 Correct 2 ms 2892 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 2 ms 2892 KB Output is correct
27 Correct 2 ms 2892 KB Output is correct
28 Correct 2 ms 2764 KB Output is correct
29 Correct 2 ms 2892 KB Output is correct
30 Correct 2 ms 2896 KB Output is correct
31 Correct 2 ms 2892 KB Output is correct
32 Correct 2 ms 2892 KB Output is correct
33 Correct 2 ms 2892 KB Output is correct
34 Correct 2 ms 2756 KB Output is correct
35 Correct 2 ms 2892 KB Output is correct
36 Correct 2 ms 2892 KB Output is correct
37 Correct 2 ms 2896 KB Output is correct
38 Correct 2 ms 2892 KB Output is correct
39 Correct 75 ms 9868 KB Output is correct
40 Correct 75 ms 9872 KB Output is correct
41 Correct 50 ms 7444 KB Output is correct
42 Correct 12 ms 3932 KB Output is correct
43 Correct 2 ms 2892 KB Output is correct
44 Correct 2 ms 2892 KB Output is correct
45 Correct 2 ms 2892 KB Output is correct
46 Correct 2 ms 2892 KB Output is correct
47 Correct 2 ms 2896 KB Output is correct
48 Correct 2 ms 2892 KB Output is correct
49 Correct 2 ms 2892 KB Output is correct
50 Correct 2 ms 2892 KB Output is correct
51 Correct 2 ms 2896 KB Output is correct
52 Correct 2 ms 2892 KB Output is correct
53 Correct 2 ms 2892 KB Output is correct
54 Correct 3 ms 2892 KB Output is correct
55 Correct 2 ms 2892 KB Output is correct
56 Correct 2 ms 2892 KB Output is correct
57 Correct 215 ms 11588 KB Output is correct
58 Correct 219 ms 11072 KB Output is correct
59 Correct 210 ms 11268 KB Output is correct
60 Correct 185 ms 10948 KB Output is correct
61 Correct 232 ms 11380 KB Output is correct
62 Correct 202 ms 11140 KB Output is correct
63 Correct 284 ms 11420 KB Output is correct
64 Correct 250 ms 11464 KB Output is correct
65 Correct 251 ms 11672 KB Output is correct
66 Correct 327 ms 11728 KB Output is correct
67 Correct 191 ms 11212 KB Output is correct
68 Correct 184 ms 11280 KB Output is correct
69 Correct 185 ms 11336 KB Output is correct
70 Correct 194 ms 11184 KB Output is correct
71 Correct 1 ms 2764 KB Output is correct
72 Correct 5 ms 3020 KB Output is correct
73 Correct 6 ms 3148 KB Output is correct
74 Correct 6 ms 3156 KB Output is correct
75 Correct 6 ms 3020 KB Output is correct
76 Correct 6 ms 3164 KB Output is correct
77 Correct 7 ms 3140 KB Output is correct
78 Correct 6 ms 3020 KB Output is correct
79 Correct 5 ms 3148 KB Output is correct
80 Correct 195 ms 11196 KB Output is correct
81 Correct 184 ms 11196 KB Output is correct
82 Correct 208 ms 11368 KB Output is correct
83 Correct 215 ms 11452 KB Output is correct
84 Correct 5 ms 3020 KB Output is correct
85 Correct 4 ms 3020 KB Output is correct
86 Correct 5 ms 3020 KB Output is correct
87 Correct 6 ms 3052 KB Output is correct
88 Correct 5 ms 3020 KB Output is correct
89 Correct 5 ms 3020 KB Output is correct
90 Correct 5 ms 3020 KB Output is correct
91 Correct 6 ms 3148 KB Output is correct
92 Correct 6 ms 3020 KB Output is correct
93 Correct 5 ms 3076 KB Output is correct
94 Correct 2 ms 2892 KB Output is correct
95 Correct 2 ms 2892 KB Output is correct
96 Correct 2 ms 2892 KB Output is correct
97 Correct 2 ms 2892 KB Output is correct
98 Correct 2 ms 2772 KB Output is correct
99 Correct 2 ms 2892 KB Output is correct
100 Correct 2 ms 2892 KB Output is correct
101 Correct 2 ms 2764 KB Output is correct
102 Correct 2 ms 2896 KB Output is correct
103 Correct 2 ms 2888 KB Output is correct
104 Correct 10 ms 3532 KB Output is correct
105 Correct 18 ms 4676 KB Output is correct
106 Correct 2 ms 2892 KB Output is correct
107 Correct 36 ms 5768 KB Output is correct
108 Correct 47 ms 6736 KB Output is correct
109 Correct 2 ms 2892 KB Output is correct
110 Correct 68 ms 8256 KB Output is correct
111 Correct 87 ms 9168 KB Output is correct
112 Correct 2 ms 2892 KB Output is correct
113 Correct 111 ms 10784 KB Output is correct
114 Incorrect 394 ms 13264 KB Output isn't correct
115 Halted 0 ms 0 KB -