# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
197186 |
2020-01-19T16:19:12 Z |
junseo |
None (KOI18_watertank) |
C++17 |
|
64 ms |
49116 KB |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1010;
int n, m, k;
int d[maxn * maxn];
vector<pii> adj[maxn * maxn];
int get_idx(int i, int j) {
if(i == 0 || i == n+1 || j == 0 || j == m+1) return 0;
return (i - 1) * m + j;
}
int main(void) {
ios_base::sync_with_stdio(0); cin.tie(0);
memset(adj, 0x3f, sizeof(adj));
cin >> n >> m >> k;
for(int i = 1; i <= n+1; ++i) {
for(int j = 1; j <= m; ++j) {
int now; cin >> now;
now = ~now ? now : 1e9 + 7;
int i1 = get_idx(i - 1, j), i2 = get_idx(i, j);
adj[i1].pb({i2, now});
adj[i2].pb({i1, now});
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m+1; ++j) {
int now; cin >> now;
now = ~now ? now : 1e9 + 7;
int i1 = get_idx(i, j - 1), i2 = get_idx(i, j);
adj[i1].pb({i2, now});
adj[i2].pb({i1, now});
}
}
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) d[get_idx(i, j)] = k;
priority_queue<pair<int, int>> pq;
d[0] = 0; pq.push({-0, 0});
while(!pq.empty()) {
int wei = -pq.top().first, now = pq.top().second;
pq.pop();
if(wei > d[now]) continue;
for(auto [nxt, nw] : adj[now]) {
if(max(wei, nw) < d[nxt]) {
d[nxt] = max(wei, nw);
pq.push({-d[nxt], nxt});
}
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) ans += d[get_idx(i, j)];
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
64 ms |
49016 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
59 ms |
48972 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
59 ms |
49052 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
49116 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
58 ms |
49016 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |