# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
804552 | 2023-08-03T09:45:37 Z | LIF | 악어의 지하 도시 (IOI11_crocodile) | C++14 | 566 ms | 74964 KB |
#include <bits/stdc++.h> #include <queue> using namespace std; int cnt = 0; struct edg { int to; int next; long long int val; }edge[2000005]; struct node { long long int val1; long long int val2; int id; }; node dis[300005]; int head[300005]; void add(int x,int y,int val) { cnt++; edge[cnt].to = y; edge[cnt].next = head[x]; edge[cnt].val = val; head[x] = cnt; } priority_queue<node> q; bool operator < (node x,node y) { return x.val2 > y.val2; } bool vis[300005]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { //cout<<"yeah"<<endl; for(int i=0;i<M;i++)add(R[i][0],R[i][1],L[i]); for(int i=0;i<M;i++)add(R[i][1],R[i][0],L[i]); for(int i=0;i<N;i++) { dis[i].val1 = 1e18; dis[i].val2 = 1e18; dis[i].id = i; } for(int i=0;i<K;i++) { dis[P[i]].val1 = 0; dis[P[i]].val2 = 0; } for(int i=0;i<K;i++) { q.push(dis[P[i]]); } while(q.empty() == false) { node now = q.top(); int val = now.val2; q.pop(); if(vis[now.id] == true)continue; vis[now.id] = true; for(int i=head[now.id];i!=0;i=edge[i].next) { int to = edge[i].to; if(dis[to].val1 > dis[now.id].val2 + edge[i].val) { dis[to].val2 = dis[to].val1; dis[to].val1 = dis[now.id].val2 + edge[i].val; if(vis[to] == false)q.push(dis[to]); } else { if(dis[to].val2 > dis[now.id].val2 + edge[i].val) { dis[to].val2 = dis[now.id].val2 + edge[i].val; if(vis[to] == false)q.push(dis[to]); } } } } return dis[0].val2; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 3 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 3 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 509 ms | 50740 KB | Output is correct |
17 | Correct | 69 ms | 18176 KB | Output is correct |
18 | Correct | 78 ms | 18792 KB | Output is correct |
19 | Correct | 566 ms | 74964 KB | Output is correct |
20 | Correct | 227 ms | 56512 KB | Output is correct |
21 | Correct | 28 ms | 7336 KB | Output is correct |
22 | Correct | 234 ms | 54780 KB | Output is correct |