답안 #521129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521129 2022-02-01T02:19:06 Z krit3379 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
493 ms 64604 KB
#include<bits/stdc++.h>
using namespace std;
#define N 100005
using pii = pair<int,int>;

int mi[2][N],deg[N];
bitset<N> vis;
vector<pair<int,int>> g[N];
priority_queue<pii,vector<pii>,greater<pii>> q;

int travel_plan(int n,int m,int r[N][2],int l[N],int k,int p[N]){
    int i,a;
    for(i=0;i<m;i++){
        g[r[i][0]].push_back({r[i][1],l[i]});
        g[r[i][1]].push_back({r[i][0],l[i]});
    }
    for(i=0;i<n;i++)mi[0][i]=mi[1][i]=1e9;
    for(i=0;i<k;i++){
        q.push({0,p[i]});
        mi[0][p[i]]=mi[1][p[i]]=0;
    }
    while(!q.empty()){
        a=q.top().second;
        q.pop();
        if(vis[a])continue;
        vis[a]=true;
        for(auto [x,w]:g[a]){
            w+=mi[1][a];
            if(w<mi[0][x])swap(mi[0][x],w);
            if(w<mi[1][x])swap(mi[1][x],w);
            if(++deg[x]>=2&&!vis[x])q.push({mi[1][x],x});
        }
        if(!a)return mi[1][0];
    }
    return mi[1][0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2700 KB Output is correct
5 Correct 2 ms 2672 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2700 KB Output is correct
5 Correct 2 ms 2672 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 2892 KB Output is correct
10 Correct 2 ms 2656 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 6 ms 3148 KB Output is correct
13 Correct 5 ms 3148 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2700 KB Output is correct
5 Correct 2 ms 2672 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 2892 KB Output is correct
10 Correct 2 ms 2656 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 6 ms 3148 KB Output is correct
13 Correct 5 ms 3148 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 463 ms 64604 KB Output is correct
17 Correct 63 ms 14120 KB Output is correct
18 Correct 79 ms 15616 KB Output is correct
19 Correct 493 ms 63660 KB Output is correct
20 Correct 254 ms 49600 KB Output is correct
21 Correct 34 ms 7700 KB Output is correct
22 Correct 343 ms 46128 KB Output is correct