# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
69146 | 2018-08-20T07:47:40 Z | red1108 | 물탱크 (KOI18_watertank) | C++17 | 1240 ms | 207564 KB |
#include <bits/stdc++.h> using namespace std; int dis[1000010]; vector<pair<int,int> > graph[1000010]; priority_queue<pair<int,int> > pq; int n, m, h; bool visit[1000100]; int main() { int i, j, ina, st,from,to; scanf("%d %d %d", &n,&m,&h); st=n*m+1; for(i=1;i<=n+1;i++) { for(j=1;j<=m;j++) { scanf("%d", &ina); if(ina==-1) ina=h; from=(i-2)*m+j; to=(i-1)*m+j; if(from<1||from>n*m) from=st; if(to<1||to>n*m) to=st; graph[from].push_back({ina,to}); graph[to].push_back({ina,from}); } } for(i=1;i<=n;i++) { for(j=1;j<=m+1;j++) { scanf("%d", &ina); if(ina==-1) ina=h; from=(i-1)*m+j-1; to=(i-1)*m+j; if(j==1) from=st; if(j==m+1) to=st; graph[from].push_back({ina,to}); graph[to].push_back({ina,from}); } } visit[st]=1; pq.push({0,st}); while(!pq.empty()) { int cur=pq.top().second; if((-1)*pq.top().first>dis[cur]){pq.pop();continue;} pq.pop(); for(auto i:graph[cur]) { if(!visit[i.second]||dis[i.second]>max(dis[cur],i.first)) { dis[i.second]=max(dis[cur],i.first); visit[i.second]=1; pq.push({-dis[i.second],i.second}); } } } long long ans=0; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { ans=ans+dis[(i-1)*m+j]; } } printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 23800 KB | Output is correct |
2 | Correct | 24 ms | 24040 KB | Output is correct |
3 | Correct | 28 ms | 24236 KB | Output is correct |
4 | Correct | 23 ms | 24236 KB | Output is correct |
5 | Correct | 27 ms | 24236 KB | Output is correct |
6 | Correct | 26 ms | 24236 KB | Output is correct |
7 | Correct | 23 ms | 24236 KB | Output is correct |
8 | Correct | 23 ms | 24236 KB | Output is correct |
9 | Correct | 22 ms | 24236 KB | Output is correct |
10 | Correct | 22 ms | 24236 KB | Output is correct |
11 | Correct | 25 ms | 24236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 24236 KB | Output is correct |
2 | Correct | 22 ms | 24236 KB | Output is correct |
3 | Correct | 23 ms | 24236 KB | Output is correct |
4 | Correct | 28 ms | 24356 KB | Output is correct |
5 | Correct | 30 ms | 24356 KB | Output is correct |
6 | Correct | 28 ms | 24356 KB | Output is correct |
7 | Correct | 30 ms | 24384 KB | Output is correct |
8 | Correct | 31 ms | 24384 KB | Output is correct |
9 | Correct | 28 ms | 24384 KB | Output is correct |
10 | Correct | 27 ms | 24440 KB | Output is correct |
11 | Correct | 29 ms | 24440 KB | Output is correct |
12 | Correct | 26 ms | 24440 KB | Output is correct |
13 | Correct | 26 ms | 24460 KB | Output is correct |
14 | Correct | 24 ms | 24472 KB | Output is correct |
15 | Correct | 25 ms | 24472 KB | Output is correct |
16 | Correct | 26 ms | 24472 KB | Output is correct |
17 | Correct | 27 ms | 24504 KB | Output is correct |
18 | Correct | 23 ms | 24504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 582 ms | 82368 KB | Output is correct |
2 | Correct | 25 ms | 82368 KB | Output is correct |
3 | Correct | 482 ms | 82368 KB | Output is correct |
4 | Correct | 572 ms | 87816 KB | Output is correct |
5 | Correct | 25 ms | 87816 KB | Output is correct |
6 | Correct | 892 ms | 101284 KB | Output is correct |
7 | Correct | 572 ms | 101284 KB | Output is correct |
8 | Correct | 610 ms | 105852 KB | Output is correct |
9 | Correct | 489 ms | 105852 KB | Output is correct |
10 | Correct | 24 ms | 105852 KB | Output is correct |
11 | Correct | 820 ms | 117132 KB | Output is correct |
12 | Correct | 23 ms | 117132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 117132 KB | Output is correct |
2 | Correct | 24 ms | 117132 KB | Output is correct |
3 | Correct | 28 ms | 117132 KB | Output is correct |
4 | Correct | 32 ms | 117132 KB | Output is correct |
5 | Correct | 24 ms | 117132 KB | Output is correct |
6 | Correct | 26 ms | 117132 KB | Output is correct |
7 | Correct | 25 ms | 117132 KB | Output is correct |
8 | Correct | 24 ms | 117132 KB | Output is correct |
9 | Correct | 25 ms | 117132 KB | Output is correct |
10 | Correct | 28 ms | 117132 KB | Output is correct |
11 | Correct | 25 ms | 117132 KB | Output is correct |
12 | Correct | 23 ms | 117132 KB | Output is correct |
13 | Correct | 31 ms | 117132 KB | Output is correct |
14 | Correct | 30 ms | 117132 KB | Output is correct |
15 | Correct | 22 ms | 117132 KB | Output is correct |
16 | Correct | 24 ms | 117132 KB | Output is correct |
17 | Correct | 24 ms | 117132 KB | Output is correct |
18 | Correct | 26 ms | 117132 KB | Output is correct |
19 | Correct | 22 ms | 117132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 117132 KB | Output is correct |
2 | Correct | 23 ms | 117132 KB | Output is correct |
3 | Correct | 24 ms | 117132 KB | Output is correct |
4 | Correct | 22 ms | 117132 KB | Output is correct |
5 | Correct | 30 ms | 117132 KB | Output is correct |
6 | Correct | 574 ms | 121188 KB | Output is correct |
7 | Correct | 24 ms | 121188 KB | Output is correct |
8 | Correct | 24 ms | 121188 KB | Output is correct |
9 | Correct | 549 ms | 121188 KB | Output is correct |
10 | Correct | 23 ms | 121188 KB | Output is correct |
11 | Correct | 23 ms | 121188 KB | Output is correct |
12 | Correct | 635 ms | 132376 KB | Output is correct |
13 | Correct | 581 ms | 132376 KB | Output is correct |
14 | Correct | 23 ms | 132376 KB | Output is correct |
15 | Correct | 575 ms | 136204 KB | Output is correct |
16 | Correct | 24 ms | 136204 KB | Output is correct |
17 | Correct | 23 ms | 136204 KB | Output is correct |
18 | Correct | 24 ms | 136204 KB | Output is correct |
19 | Correct | 536 ms | 143092 KB | Output is correct |
20 | Correct | 25 ms | 143092 KB | Output is correct |
21 | Correct | 1240 ms | 163392 KB | Output is correct |
22 | Correct | 30 ms | 163392 KB | Output is correct |
23 | Correct | 26 ms | 163392 KB | Output is correct |
24 | Correct | 29 ms | 163392 KB | Output is correct |
25 | Correct | 30 ms | 163392 KB | Output is correct |
26 | Correct | 23 ms | 163392 KB | Output is correct |
27 | Correct | 29 ms | 163392 KB | Output is correct |
28 | Correct | 967 ms | 166448 KB | Output is correct |
29 | Correct | 996 ms | 170960 KB | Output is correct |
30 | Correct | 569 ms | 170960 KB | Output is correct |
31 | Correct | 607 ms | 175672 KB | Output is correct |
32 | Correct | 618 ms | 179160 KB | Output is correct |
33 | Correct | 25 ms | 179160 KB | Output is correct |
34 | Correct | 508 ms | 179160 KB | Output is correct |
35 | Correct | 26 ms | 179160 KB | Output is correct |
36 | Correct | 28 ms | 179160 KB | Output is correct |
37 | Correct | 24 ms | 179160 KB | Output is correct |
38 | Correct | 839 ms | 192624 KB | Output is correct |
39 | Correct | 1137 ms | 204624 KB | Output is correct |
40 | Correct | 24 ms | 204624 KB | Output is correct |
41 | Correct | 27 ms | 204624 KB | Output is correct |
42 | Correct | 27 ms | 204624 KB | Output is correct |
43 | Correct | 27 ms | 204624 KB | Output is correct |
44 | Correct | 545 ms | 204624 KB | Output is correct |
45 | Correct | 1099 ms | 207564 KB | Output is correct |
46 | Correct | 26 ms | 207564 KB | Output is correct |