Submission #322247

# Submission time Handle Problem Language Result Execution time Memory
322247 2020-11-14T10:27:41 Z tjdgus4384 None (KOI18_watertank) C++14
15 / 100
533 ms 94956 KB
#include<bits/stdc++.h>
using namespace std;
int N, M, H, t, d[1010][1010], ans;
vector<pair<pair<int, int>, int> > v[1010][1010];
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > q;

int main(){
    scanf("%d %d %d", &N, &M, &H);
    for(int i = 0;i < N;i++){
        for(int j = 0;j < M;j++){
            d[i][j] = H;
        }
    }
    for(int i = 0;i < N+1;i++){
        for(int j = 0;j < M;j++){
            scanf("%d", &t);
            if(t == -1) continue;
            if(i == 0){
                q.push({t, {0, j}});
                d[0][j] = t;
            }
            else if(i == N){
                q.push({t, {N-1, j}});
                d[N-1][j] = t;
            }
            else{
                v[i-1][j].push_back({{i, j}, t});
                v[i][j].push_back({{i-1, j}, t});
            }
        }
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < M+1;j++){
            scanf("%d", &t);
            if(t == -1) continue;
            if(j == 0){
                q.push({t, {i, 0}});
                d[i][0] = t;
            }
            else if(j == M){
                q.push({t, {i, M-1}});
                d[i][M-1] = t;
            }
            else{
                v[i][j-1].push_back({{i, j}, t});
                v[i][j].push_back({{i, j-1}, t});
            }
        }
    }

    while(!q.empty()){
        int q1 = q.top().first;
        int qx = q.top().second.first;
        int qy = q.top().second.second;
        q.pop();
        for(int i = 0;i < v[qx][qy].size();i++){
            int nx = v[qx][qy][i].first.first;
            int ny = v[qx][qy][i].first.second;
            if(d[nx][ny] > max(q1, v[qx][qy][i].second)){
                d[nx][ny] = max(q1, v[qx][qy][i].second);
                q.push({d[nx][ny], {nx, ny}});
            }
        }
    }

    for(int i = 0;i < N;i++){
        for(int j = 0;j < M;j++){
            ans += d[i][j];
        }
    }
    printf("%d", ans);
    return 0;
}

Compilation message

watertank.cpp: In function 'int main()':
watertank.cpp:56:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for(int i = 0;i < v[qx][qy].size();i++){
      |                       ~~^~~~~~~~~~~~~~~~~~
watertank.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d %d %d", &N, &M, &H);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
watertank.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |             scanf("%d", &t);
      |             ~~~~~^~~~~~~~~~
watertank.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |             scanf("%d", &t);
      |             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 24300 KB Output is correct
2 Incorrect 17 ms 24300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 24300 KB Output is correct
2 Incorrect 16 ms 24320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 203 ms 28296 KB Output is correct
2 Correct 16 ms 24300 KB Output is correct
3 Correct 205 ms 37100 KB Output is correct
4 Correct 268 ms 54892 KB Output is correct
5 Correct 16 ms 24300 KB Output is correct
6 Correct 462 ms 74348 KB Output is correct
7 Correct 218 ms 42572 KB Output is correct
8 Correct 533 ms 94956 KB Output is correct
9 Correct 221 ms 43688 KB Output is correct
10 Correct 16 ms 24228 KB Output is correct
11 Correct 528 ms 82016 KB Output is correct
12 Correct 16 ms 24300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 24684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 24684 KB Output isn't correct
2 Halted 0 ms 0 KB -