답안 #896369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896369 2024-01-01T10:29:54 Z PenguinsAreCute Voting Cities (NOI22_votingcity) C++17
100 / 100
129 ms 38404 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL_MAX LONG_LONG_MAX
#define LL_MIN LONG_LONG_MIN
#define speed ios_base::sync_with_stdio(false); cin.tie(0)
#define stMx(a,b) a = max(a,b)
#define stMn(a,b) a = min(a,b)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ii> vii;
typedef set<ii> sii;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define HASTC 0
vii adj[161210];
priority_queue<ii, vector<ii>, greater<ii> > pq;
int dist[161210], best[161210];
#define MP(a, b) make_pair(a, b)
void dijkstra(int source) {
    pq.push(ii(0, source)); dist[source] = 0;
    while(!pq.empty()){
        ii c = pq.top(); pq.pop();
        int x = c.second, d = c.first;
        if(d != dist[x]) continue; 
        for(auto i : adj[x]){
            if(dist[i.first] > d + i.second){
                best[i.first]=x;
                dist[i.first] = d + i.second;
                pq.push(ii(dist[i.first], i.first));
            }
        }
    }
}
void solvetc(int idx) {
    int N, E, K, T, U, V, C, Q, S, P[5]; cin >> N >> E >> K;
    REP(i,0,K) {
        cin>>T;
        adj[161209].pb(ii(T<<5,0));
    }
    REP(i,0,E) {
        cin>>U>>V>>C;
        REP(j,0,32) {
            adj[(V<<5)+j].pb(ii((U<<5)+j,C));
            REP(k,0,5) if(!(j&(1<<k))) adj[(V<<5)+j].pb(ii((U<<5)+j+(1<<k),C/10*(9-k)));
        }
    }
    cin>>Q;
    REP(i,0,161210) dist[i]=6942012102010;
    dijkstra(161209);
    while(Q--) {
        cin>>S; REP(i,0,5)cin>>P[i];
        int min_dist=6942012102010;
        REP(i,0,32) {
            int cur_dist=dist[(S<<5)+i];
            REP(j,0,5) if(i&(1<<j)) cur_dist+=(P[j]==-1?6942012102010:P[j]);
            min_dist=min(min_dist,cur_dist);
        }
        cout<<(min_dist==6942012102010?-1:min_dist)<<"\n";
    }
}
int32_t main() {
    int tc;
    if(HASTC) cin>>tc;
    else tc=1;
    for(int i=0;i<tc;i++) solvetc(i);    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 96 ms 33488 KB Output is correct
7 Correct 53 ms 20000 KB Output is correct
8 Correct 119 ms 33488 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 96 ms 33488 KB Output is correct
7 Correct 53 ms 20000 KB Output is correct
8 Correct 119 ms 33488 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 120 ms 38404 KB Output is correct
12 Correct 45 ms 20236 KB Output is correct
13 Correct 108 ms 33660 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 48 ms 32112 KB Output is correct
7 Correct 39 ms 20060 KB Output is correct
8 Correct 100 ms 33488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 96 ms 33488 KB Output is correct
7 Correct 53 ms 20000 KB Output is correct
8 Correct 119 ms 33488 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 48 ms 32112 KB Output is correct
12 Correct 39 ms 20060 KB Output is correct
13 Correct 100 ms 33488 KB Output is correct
14 Correct 95 ms 33584 KB Output is correct
15 Correct 51 ms 20060 KB Output is correct
16 Correct 106 ms 33484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 34508 KB Output is correct
2 Correct 119 ms 36800 KB Output is correct
3 Correct 63 ms 20556 KB Output is correct
4 Correct 108 ms 33564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9560 KB Output is correct
2 Correct 7 ms 9564 KB Output is correct
3 Correct 3 ms 6748 KB Output is correct
4 Correct 6 ms 9052 KB Output is correct
5 Correct 7 ms 9308 KB Output is correct
6 Correct 3 ms 6748 KB Output is correct
7 Correct 7 ms 9652 KB Output is correct
8 Correct 8 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 33744 KB Output is correct
2 Correct 41 ms 20048 KB Output is correct
3 Correct 95 ms 33484 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 96 ms 33488 KB Output is correct
7 Correct 53 ms 20000 KB Output is correct
8 Correct 119 ms 33488 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 120 ms 38404 KB Output is correct
12 Correct 45 ms 20236 KB Output is correct
13 Correct 108 ms 33660 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 48 ms 32112 KB Output is correct
17 Correct 39 ms 20060 KB Output is correct
18 Correct 100 ms 33488 KB Output is correct
19 Correct 95 ms 33584 KB Output is correct
20 Correct 51 ms 20060 KB Output is correct
21 Correct 106 ms 33484 KB Output is correct
22 Correct 118 ms 34508 KB Output is correct
23 Correct 119 ms 36800 KB Output is correct
24 Correct 63 ms 20556 KB Output is correct
25 Correct 108 ms 33564 KB Output is correct
26 Correct 7 ms 9560 KB Output is correct
27 Correct 7 ms 9564 KB Output is correct
28 Correct 3 ms 6748 KB Output is correct
29 Correct 6 ms 9052 KB Output is correct
30 Correct 7 ms 9308 KB Output is correct
31 Correct 3 ms 6748 KB Output is correct
32 Correct 7 ms 9652 KB Output is correct
33 Correct 8 ms 9560 KB Output is correct
34 Correct 2 ms 6492 KB Output is correct
35 Correct 2 ms 6492 KB Output is correct
36 Correct 2 ms 6492 KB Output is correct
37 Correct 129 ms 37060 KB Output is correct
38 Correct 125 ms 37252 KB Output is correct
39 Correct 104 ms 33488 KB Output is correct
40 Correct 2 ms 6492 KB Output is correct
41 Correct 4 ms 7000 KB Output is correct
42 Correct 128 ms 37064 KB Output is correct
43 Correct 127 ms 37820 KB Output is correct
44 Correct 103 ms 33488 KB Output is correct
45 Correct 54 ms 20708 KB Output is correct