Submission #522797

# Submission time Handle Problem Language Result Execution time Memory
522797 2022-02-05T21:49:13 Z Deepesson Dreaming (IOI13_dreaming) C++17
47 / 100
417 ms 13340 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(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(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){
      |                 ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 93 ms 9280 KB Output is correct
2 Correct 89 ms 9276 KB Output is correct
3 Correct 57 ms 7136 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 11 ms 3644 KB Output is correct
6 Correct 22 ms 4488 KB Output is correct
7 Correct 2 ms 2884 KB Output is correct
8 Correct 43 ms 5828 KB Output is correct
9 Correct 56 ms 6744 KB Output is correct
10 Correct 3 ms 2876 KB Output is correct
11 Correct 93 ms 7800 KB Output is correct
12 Correct 103 ms 8748 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2892 KB Output is correct
2 Correct 2 ms 2892 KB Output is correct
3 Correct 2 ms 2896 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 2892 KB Output is correct
7 Correct 2 ms 2892 KB Output is correct
8 Correct 2 ms 2892 KB Output is correct
9 Correct 2 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 2896 KB Output is correct
14 Correct 2 ms 2892 KB Output is correct
15 Correct 2 ms 2768 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 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2892 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 2764 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 9280 KB Output is correct
2 Correct 89 ms 9276 KB Output is correct
3 Correct 57 ms 7136 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 11 ms 3644 KB Output is correct
6 Correct 22 ms 4488 KB Output is correct
7 Correct 2 ms 2884 KB Output is correct
8 Correct 43 ms 5828 KB Output is correct
9 Correct 56 ms 6744 KB Output is correct
10 Correct 3 ms 2876 KB Output is correct
11 Correct 93 ms 7800 KB Output is correct
12 Correct 103 ms 8748 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 2892 KB Output is correct
16 Correct 2 ms 2896 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 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2892 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 2892 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 2 ms 2896 KB Output is correct
27 Correct 2 ms 2892 KB Output is correct
28 Correct 2 ms 2768 KB Output is correct
29 Correct 2 ms 2892 KB Output is correct
30 Correct 2 ms 2892 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 2892 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 2764 KB Output is correct
38 Correct 2 ms 2892 KB Output is correct
39 Correct 89 ms 9268 KB Output is correct
40 Correct 112 ms 9248 KB Output is correct
41 Correct 57 ms 7232 KB Output is correct
42 Correct 14 ms 3916 KB Output is correct
43 Correct 2 ms 2764 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 2892 KB Output is correct
48 Correct 2 ms 2892 KB Output is correct
49 Correct 2 ms 2772 KB Output is correct
50 Correct 4 ms 2892 KB Output is correct
51 Correct 2 ms 2892 KB Output is correct
52 Correct 2 ms 2892 KB Output is correct
53 Correct 2 ms 2892 KB Output is correct
54 Correct 2 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 293 ms 10844 KB Output is correct
58 Correct 270 ms 10352 KB Output is correct
59 Correct 257 ms 10532 KB Output is correct
60 Correct 241 ms 10116 KB Output is correct
61 Correct 262 ms 10448 KB Output is correct
62 Correct 297 ms 10280 KB Output is correct
63 Correct 295 ms 10664 KB Output is correct
64 Correct 318 ms 10720 KB Output is correct
65 Correct 299 ms 10740 KB Output is correct
66 Correct 317 ms 10744 KB Output is correct
67 Correct 231 ms 10668 KB Output is correct
68 Correct 237 ms 10556 KB Output is correct
69 Correct 221 ms 10184 KB Output is correct
70 Correct 223 ms 10208 KB Output is correct
71 Correct 2 ms 2764 KB Output is correct
72 Correct 7 ms 3020 KB Output is correct
73 Correct 7 ms 3032 KB Output is correct
74 Correct 7 ms 3148 KB Output is correct
75 Correct 7 ms 3020 KB Output is correct
76 Correct 8 ms 3164 KB Output is correct
77 Correct 8 ms 3148 KB Output is correct
78 Correct 6 ms 3020 KB Output is correct
79 Correct 6 ms 3040 KB Output is correct
80 Correct 246 ms 10544 KB Output is correct
81 Correct 275 ms 10544 KB Output is correct
82 Correct 266 ms 10428 KB Output is correct
83 Correct 278 ms 10680 KB Output is correct
84 Correct 6 ms 3108 KB Output is correct
85 Correct 5 ms 3020 KB Output is correct
86 Correct 6 ms 3020 KB Output is correct
87 Correct 6 ms 3020 KB Output is correct
88 Correct 6 ms 3076 KB Output is correct
89 Correct 7 ms 3032 KB Output is correct
90 Correct 6 ms 3020 KB Output is correct
91 Correct 7 ms 3088 KB Output is correct
92 Correct 6 ms 3020 KB Output is correct
93 Correct 7 ms 3020 KB Output is correct
94 Correct 2 ms 2892 KB Output is correct
95 Correct 2 ms 2892 KB Output is correct
96 Correct 3 ms 2764 KB Output is correct
97 Correct 2 ms 2892 KB Output is correct
98 Correct 2 ms 2892 KB Output is correct
99 Correct 2 ms 2892 KB Output is correct
100 Correct 2 ms 2896 KB Output is correct
101 Correct 2 ms 2892 KB Output is correct
102 Correct 2 ms 2892 KB Output is correct
103 Correct 2 ms 2768 KB Output is correct
104 Correct 11 ms 3652 KB Output is correct
105 Correct 21 ms 4564 KB Output is correct
106 Correct 2 ms 2892 KB Output is correct
107 Correct 43 ms 5872 KB Output is correct
108 Correct 56 ms 6724 KB Output is correct
109 Correct 2 ms 2892 KB Output is correct
110 Correct 80 ms 7748 KB Output is correct
111 Correct 109 ms 8748 KB Output is correct
112 Correct 2 ms 2892 KB Output is correct
113 Correct 138 ms 9836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 417 ms 13340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2892 KB Output is correct
2 Correct 2 ms 2892 KB Output is correct
3 Correct 2 ms 2896 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 2892 KB Output is correct
7 Correct 2 ms 2892 KB Output is correct
8 Correct 2 ms 2892 KB Output is correct
9 Correct 2 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 2896 KB Output is correct
14 Correct 2 ms 2892 KB Output is correct
15 Correct 2 ms 2768 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 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2892 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 2764 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 4 ms 2892 KB Output is correct
27 Correct 10 ms 3080 KB Output is correct
28 Correct 8 ms 3164 KB Output is correct
29 Incorrect 4 ms 2892 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 93 ms 9280 KB Output is correct
2 Correct 89 ms 9276 KB Output is correct
3 Correct 57 ms 7136 KB Output is correct
4 Correct 13 ms 3920 KB Output is correct
5 Correct 11 ms 3644 KB Output is correct
6 Correct 22 ms 4488 KB Output is correct
7 Correct 2 ms 2884 KB Output is correct
8 Correct 43 ms 5828 KB Output is correct
9 Correct 56 ms 6744 KB Output is correct
10 Correct 3 ms 2876 KB Output is correct
11 Correct 93 ms 7800 KB Output is correct
12 Correct 103 ms 8748 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 2892 KB Output is correct
16 Correct 2 ms 2896 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 2892 KB Output is correct
20 Correct 2 ms 2892 KB Output is correct
21 Correct 2 ms 2892 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 2892 KB Output is correct
25 Correct 2 ms 2892 KB Output is correct
26 Correct 2 ms 2896 KB Output is correct
27 Correct 2 ms 2892 KB Output is correct
28 Correct 2 ms 2768 KB Output is correct
29 Correct 2 ms 2892 KB Output is correct
30 Correct 2 ms 2892 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 2892 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 2764 KB Output is correct
38 Correct 2 ms 2892 KB Output is correct
39 Correct 89 ms 9268 KB Output is correct
40 Correct 112 ms 9248 KB Output is correct
41 Correct 57 ms 7232 KB Output is correct
42 Correct 14 ms 3916 KB Output is correct
43 Correct 2 ms 2764 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 2892 KB Output is correct
48 Correct 2 ms 2892 KB Output is correct
49 Correct 2 ms 2772 KB Output is correct
50 Correct 4 ms 2892 KB Output is correct
51 Correct 2 ms 2892 KB Output is correct
52 Correct 2 ms 2892 KB Output is correct
53 Correct 2 ms 2892 KB Output is correct
54 Correct 2 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 293 ms 10844 KB Output is correct
58 Correct 270 ms 10352 KB Output is correct
59 Correct 257 ms 10532 KB Output is correct
60 Correct 241 ms 10116 KB Output is correct
61 Correct 262 ms 10448 KB Output is correct
62 Correct 297 ms 10280 KB Output is correct
63 Correct 295 ms 10664 KB Output is correct
64 Correct 318 ms 10720 KB Output is correct
65 Correct 299 ms 10740 KB Output is correct
66 Correct 317 ms 10744 KB Output is correct
67 Correct 231 ms 10668 KB Output is correct
68 Correct 237 ms 10556 KB Output is correct
69 Correct 221 ms 10184 KB Output is correct
70 Correct 223 ms 10208 KB Output is correct
71 Correct 2 ms 2764 KB Output is correct
72 Correct 7 ms 3020 KB Output is correct
73 Correct 7 ms 3032 KB Output is correct
74 Correct 7 ms 3148 KB Output is correct
75 Correct 7 ms 3020 KB Output is correct
76 Correct 8 ms 3164 KB Output is correct
77 Correct 8 ms 3148 KB Output is correct
78 Correct 6 ms 3020 KB Output is correct
79 Correct 6 ms 3040 KB Output is correct
80 Correct 246 ms 10544 KB Output is correct
81 Correct 275 ms 10544 KB Output is correct
82 Correct 266 ms 10428 KB Output is correct
83 Correct 278 ms 10680 KB Output is correct
84 Correct 6 ms 3108 KB Output is correct
85 Correct 5 ms 3020 KB Output is correct
86 Correct 6 ms 3020 KB Output is correct
87 Correct 6 ms 3020 KB Output is correct
88 Correct 6 ms 3076 KB Output is correct
89 Correct 7 ms 3032 KB Output is correct
90 Correct 6 ms 3020 KB Output is correct
91 Correct 7 ms 3088 KB Output is correct
92 Correct 6 ms 3020 KB Output is correct
93 Correct 7 ms 3020 KB Output is correct
94 Correct 2 ms 2892 KB Output is correct
95 Correct 2 ms 2892 KB Output is correct
96 Correct 3 ms 2764 KB Output is correct
97 Correct 2 ms 2892 KB Output is correct
98 Correct 2 ms 2892 KB Output is correct
99 Correct 2 ms 2892 KB Output is correct
100 Correct 2 ms 2896 KB Output is correct
101 Correct 2 ms 2892 KB Output is correct
102 Correct 2 ms 2892 KB Output is correct
103 Correct 2 ms 2768 KB Output is correct
104 Correct 11 ms 3652 KB Output is correct
105 Correct 21 ms 4564 KB Output is correct
106 Correct 2 ms 2892 KB Output is correct
107 Correct 43 ms 5872 KB Output is correct
108 Correct 56 ms 6724 KB Output is correct
109 Correct 2 ms 2892 KB Output is correct
110 Correct 80 ms 7748 KB Output is correct
111 Correct 109 ms 8748 KB Output is correct
112 Correct 2 ms 2892 KB Output is correct
113 Correct 138 ms 9836 KB Output is correct
114 Incorrect 417 ms 13340 KB Output isn't correct
115 Halted 0 ms 0 KB -