답안 #680233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680233 2023-01-10T10:04:10 Z abcvuitunggio Relay Marathon (NOI20_relaymarathon) C++17
100 / 100
4264 ms 125900 KB
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+10;
int a[100001],d[100001],ch[100001],n,m,k,u,v,w,res=INF*2;
vector <pair <int, int>> ke[100001];
vector <int> ve[4];
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int f(int s, int e){
    priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> q;
    for (int i=1;i<=n;i++){
        d[i]=INF;
        ch[i]=0;
    }
    for (int i:ve[s]){
        d[i]=0;
        q.push({0,i});
    }
    for (int i:ve[e])
        ch[i]=1;
    while (!q.empty()){
        auto [du,u]=q.top();
        q.pop();
        if (ch[u])
            return du;
        if (du!=d[u])
            continue;
        for (auto [v,w]:ke[u])
            if (d[v]>d[u]+w){
                d[v]=d[u]+w;
                q.push({d[v],v});
            }
    }
    return INF;
}
int main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n >> m >> k;
    while (m--){
        cin >> u >> v >> w;
        ke[u].push_back({v,w});
        ke[v].push_back({u,w});
    }
    for (int i=1;i<=k;i++)
        cin >> a[i];
    chrono::milliseconds ms(3000);
    chrono::time_point<chrono::system_clock> end=chrono::system_clock::now()+ms;
    while (chrono::system_clock::now()<end){
        shuffle(a+1,a+k+1,rd);
        for (int i=0;i<4;i++)
            ve[i].clear();
        for (int i=1;i<=k;i++)
            ve[rd()%4].push_back(a[i]);
        res=min(res,f(0,1)+f(2,3));
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2982 ms 2764 KB Output is correct
2 Correct 2972 ms 2716 KB Output is correct
3 Correct 2969 ms 2668 KB Output is correct
4 Correct 2979 ms 2664 KB Output is correct
5 Correct 2969 ms 2672 KB Output is correct
6 Correct 2970 ms 2668 KB Output is correct
7 Correct 2977 ms 2724 KB Output is correct
8 Correct 2977 ms 2720 KB Output is correct
9 Correct 2985 ms 2664 KB Output is correct
10 Correct 2978 ms 2792 KB Output is correct
11 Correct 2985 ms 2764 KB Output is correct
12 Correct 2980 ms 2672 KB Output is correct
13 Correct 2983 ms 2720 KB Output is correct
14 Correct 2984 ms 2720 KB Output is correct
15 Correct 2979 ms 2720 KB Output is correct
16 Correct 2968 ms 2668 KB Output is correct
17 Correct 2984 ms 2644 KB Output is correct
18 Correct 2992 ms 2672 KB Output is correct
19 Correct 2978 ms 2728 KB Output is correct
20 Correct 2993 ms 2776 KB Output is correct
21 Correct 3001 ms 2696 KB Output is correct
22 Correct 2989 ms 2668 KB Output is correct
23 Correct 2986 ms 2764 KB Output is correct
24 Correct 2997 ms 2676 KB Output is correct
25 Correct 2970 ms 2672 KB Output is correct
26 Correct 2991 ms 2680 KB Output is correct
27 Correct 2979 ms 2672 KB Output is correct
28 Correct 2977 ms 2724 KB Output is correct
29 Correct 2974 ms 2720 KB Output is correct
30 Correct 2966 ms 2724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2982 ms 2764 KB Output is correct
2 Correct 2972 ms 2716 KB Output is correct
3 Correct 2969 ms 2668 KB Output is correct
4 Correct 2979 ms 2664 KB Output is correct
5 Correct 2969 ms 2672 KB Output is correct
6 Correct 2970 ms 2668 KB Output is correct
7 Correct 2977 ms 2724 KB Output is correct
8 Correct 2977 ms 2720 KB Output is correct
9 Correct 2985 ms 2664 KB Output is correct
10 Correct 2978 ms 2792 KB Output is correct
11 Correct 2985 ms 2764 KB Output is correct
12 Correct 2980 ms 2672 KB Output is correct
13 Correct 2983 ms 2720 KB Output is correct
14 Correct 2984 ms 2720 KB Output is correct
15 Correct 2979 ms 2720 KB Output is correct
16 Correct 2968 ms 2668 KB Output is correct
17 Correct 2984 ms 2644 KB Output is correct
18 Correct 2992 ms 2672 KB Output is correct
19 Correct 2978 ms 2728 KB Output is correct
20 Correct 2993 ms 2776 KB Output is correct
21 Correct 3001 ms 2696 KB Output is correct
22 Correct 2989 ms 2668 KB Output is correct
23 Correct 2986 ms 2764 KB Output is correct
24 Correct 2997 ms 2676 KB Output is correct
25 Correct 2970 ms 2672 KB Output is correct
26 Correct 2991 ms 2680 KB Output is correct
27 Correct 2979 ms 2672 KB Output is correct
28 Correct 2977 ms 2724 KB Output is correct
29 Correct 2974 ms 2720 KB Output is correct
30 Correct 2966 ms 2724 KB Output is correct
31 Correct 2986 ms 2696 KB Output is correct
32 Correct 2982 ms 2704 KB Output is correct
33 Correct 2994 ms 2724 KB Output is correct
34 Correct 2988 ms 2688 KB Output is correct
35 Correct 2981 ms 2676 KB Output is correct
36 Correct 2994 ms 2852 KB Output is correct
37 Correct 2995 ms 2960 KB Output is correct
38 Correct 2971 ms 2736 KB Output is correct
39 Correct 3000 ms 5620 KB Output is correct
40 Correct 2983 ms 3440 KB Output is correct
41 Correct 2970 ms 2764 KB Output is correct
42 Correct 2977 ms 3456 KB Output is correct
43 Correct 2989 ms 2824 KB Output is correct
44 Correct 2982 ms 2728 KB Output is correct
45 Correct 2980 ms 2688 KB Output is correct
46 Correct 3003 ms 5656 KB Output is correct
47 Correct 2978 ms 3160 KB Output is correct
48 Correct 2993 ms 5624 KB Output is correct
49 Correct 2998 ms 5636 KB Output is correct
50 Correct 2978 ms 2712 KB Output is correct
51 Correct 2977 ms 2732 KB Output is correct
52 Correct 2986 ms 2708 KB Output is correct
53 Correct 2976 ms 4516 KB Output is correct
54 Correct 3010 ms 5616 KB Output is correct
55 Correct 2970 ms 2704 KB Output is correct
56 Correct 2978 ms 2684 KB Output is correct
57 Correct 2971 ms 2764 KB Output is correct
58 Correct 3006 ms 5644 KB Output is correct
59 Correct 2986 ms 2764 KB Output is correct
60 Correct 2977 ms 2744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3015 ms 6864 KB Output is correct
2 Correct 2970 ms 4032 KB Output is correct
3 Correct 3907 ms 65748 KB Output is correct
4 Correct 3366 ms 34196 KB Output is correct
5 Correct 3053 ms 10724 KB Output is correct
6 Correct 3052 ms 9036 KB Output is correct
7 Correct 3069 ms 11512 KB Output is correct
8 Correct 3041 ms 6956 KB Output is correct
9 Correct 3035 ms 8852 KB Output is correct
10 Correct 3030 ms 7788 KB Output is correct
11 Correct 4024 ms 67988 KB Output is correct
12 Correct 3037 ms 7772 KB Output is correct
13 Correct 3219 ms 22588 KB Output is correct
14 Correct 3051 ms 10704 KB Output is correct
15 Correct 3968 ms 67076 KB Output is correct
16 Correct 3015 ms 6584 KB Output is correct
17 Correct 3601 ms 48796 KB Output is correct
18 Correct 2987 ms 4196 KB Output is correct
19 Correct 4016 ms 67140 KB Output is correct
20 Correct 3069 ms 10140 KB Output is correct
21 Correct 3056 ms 10028 KB Output is correct
22 Correct 3013 ms 7512 KB Output is correct
23 Correct 3015 ms 6092 KB Output is correct
24 Correct 3713 ms 57088 KB Output is correct
25 Correct 3044 ms 8532 KB Output is correct
26 Correct 3022 ms 6676 KB Output is correct
27 Correct 3034 ms 8032 KB Output is correct
28 Correct 3013 ms 5044 KB Output is correct
29 Correct 3069 ms 10752 KB Output is correct
30 Correct 3156 ms 16196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2982 ms 2764 KB Output is correct
2 Correct 2972 ms 2716 KB Output is correct
3 Correct 2969 ms 2668 KB Output is correct
4 Correct 2979 ms 2664 KB Output is correct
5 Correct 2969 ms 2672 KB Output is correct
6 Correct 2970 ms 2668 KB Output is correct
7 Correct 2977 ms 2724 KB Output is correct
8 Correct 2977 ms 2720 KB Output is correct
9 Correct 2985 ms 2664 KB Output is correct
10 Correct 2978 ms 2792 KB Output is correct
11 Correct 2985 ms 2764 KB Output is correct
12 Correct 2980 ms 2672 KB Output is correct
13 Correct 2983 ms 2720 KB Output is correct
14 Correct 2984 ms 2720 KB Output is correct
15 Correct 2979 ms 2720 KB Output is correct
16 Correct 2968 ms 2668 KB Output is correct
17 Correct 2984 ms 2644 KB Output is correct
18 Correct 2992 ms 2672 KB Output is correct
19 Correct 2978 ms 2728 KB Output is correct
20 Correct 2993 ms 2776 KB Output is correct
21 Correct 3001 ms 2696 KB Output is correct
22 Correct 2989 ms 2668 KB Output is correct
23 Correct 2986 ms 2764 KB Output is correct
24 Correct 2997 ms 2676 KB Output is correct
25 Correct 2970 ms 2672 KB Output is correct
26 Correct 2991 ms 2680 KB Output is correct
27 Correct 2979 ms 2672 KB Output is correct
28 Correct 2977 ms 2724 KB Output is correct
29 Correct 2974 ms 2720 KB Output is correct
30 Correct 2966 ms 2724 KB Output is correct
31 Correct 2986 ms 2696 KB Output is correct
32 Correct 2982 ms 2704 KB Output is correct
33 Correct 2994 ms 2724 KB Output is correct
34 Correct 2988 ms 2688 KB Output is correct
35 Correct 2981 ms 2676 KB Output is correct
36 Correct 2994 ms 2852 KB Output is correct
37 Correct 2995 ms 2960 KB Output is correct
38 Correct 2971 ms 2736 KB Output is correct
39 Correct 3000 ms 5620 KB Output is correct
40 Correct 2983 ms 3440 KB Output is correct
41 Correct 2970 ms 2764 KB Output is correct
42 Correct 2977 ms 3456 KB Output is correct
43 Correct 2989 ms 2824 KB Output is correct
44 Correct 2982 ms 2728 KB Output is correct
45 Correct 2980 ms 2688 KB Output is correct
46 Correct 3003 ms 5656 KB Output is correct
47 Correct 2978 ms 3160 KB Output is correct
48 Correct 2993 ms 5624 KB Output is correct
49 Correct 2998 ms 5636 KB Output is correct
50 Correct 2978 ms 2712 KB Output is correct
51 Correct 2977 ms 2732 KB Output is correct
52 Correct 2986 ms 2708 KB Output is correct
53 Correct 2976 ms 4516 KB Output is correct
54 Correct 3010 ms 5616 KB Output is correct
55 Correct 2970 ms 2704 KB Output is correct
56 Correct 2978 ms 2684 KB Output is correct
57 Correct 2971 ms 2764 KB Output is correct
58 Correct 3006 ms 5644 KB Output is correct
59 Correct 2986 ms 2764 KB Output is correct
60 Correct 2977 ms 2744 KB Output is correct
61 Correct 3015 ms 6864 KB Output is correct
62 Correct 2970 ms 4032 KB Output is correct
63 Correct 3907 ms 65748 KB Output is correct
64 Correct 3366 ms 34196 KB Output is correct
65 Correct 3053 ms 10724 KB Output is correct
66 Correct 3052 ms 9036 KB Output is correct
67 Correct 3069 ms 11512 KB Output is correct
68 Correct 3041 ms 6956 KB Output is correct
69 Correct 3035 ms 8852 KB Output is correct
70 Correct 3030 ms 7788 KB Output is correct
71 Correct 4024 ms 67988 KB Output is correct
72 Correct 3037 ms 7772 KB Output is correct
73 Correct 3219 ms 22588 KB Output is correct
74 Correct 3051 ms 10704 KB Output is correct
75 Correct 3968 ms 67076 KB Output is correct
76 Correct 3015 ms 6584 KB Output is correct
77 Correct 3601 ms 48796 KB Output is correct
78 Correct 2987 ms 4196 KB Output is correct
79 Correct 4016 ms 67140 KB Output is correct
80 Correct 3069 ms 10140 KB Output is correct
81 Correct 3056 ms 10028 KB Output is correct
82 Correct 3013 ms 7512 KB Output is correct
83 Correct 3015 ms 6092 KB Output is correct
84 Correct 3713 ms 57088 KB Output is correct
85 Correct 3044 ms 8532 KB Output is correct
86 Correct 3022 ms 6676 KB Output is correct
87 Correct 3034 ms 8032 KB Output is correct
88 Correct 3013 ms 5044 KB Output is correct
89 Correct 3069 ms 10752 KB Output is correct
90 Correct 3156 ms 16196 KB Output is correct
91 Correct 3045 ms 8160 KB Output is correct
92 Correct 4116 ms 116972 KB Output is correct
93 Correct 3060 ms 13536 KB Output is correct
94 Correct 3612 ms 67264 KB Output is correct
95 Correct 2984 ms 4084 KB Output is correct
96 Correct 2987 ms 4300 KB Output is correct
97 Correct 3109 ms 17248 KB Output is correct
98 Correct 3010 ms 9720 KB Output is correct
99 Correct 3014 ms 10516 KB Output is correct
100 Correct 4143 ms 124600 KB Output is correct
101 Correct 3399 ms 45580 KB Output is correct
102 Correct 3369 ms 44964 KB Output is correct
103 Correct 3761 ms 86988 KB Output is correct
104 Correct 3904 ms 95880 KB Output is correct
105 Correct 3013 ms 7628 KB Output is correct
106 Correct 3783 ms 87448 KB Output is correct
107 Correct 3181 ms 24764 KB Output is correct
108 Correct 3057 ms 12572 KB Output is correct
109 Correct 3006 ms 5492 KB Output is correct
110 Correct 3001 ms 7156 KB Output is correct
111 Correct 3057 ms 12868 KB Output is correct
112 Correct 4200 ms 125164 KB Output is correct
113 Correct 4264 ms 125900 KB Output is correct
114 Correct 3078 ms 12588 KB Output is correct
115 Correct 3391 ms 45388 KB Output is correct
116 Correct 4127 ms 114460 KB Output is correct
117 Correct 3725 ms 84860 KB Output is correct
118 Correct 3727 ms 75888 KB Output is correct
119 Correct 4024 ms 101376 KB Output is correct
120 Correct 3551 ms 58704 KB Output is correct