Submission #81610

# Submission time Handle Problem Language Result Execution time Memory
81610 2018-10-25T15:03:55 Z tjdgus4384 None (KOI18_watertank) C++14
45 / 100
3000 ms 12484 KB
#include<cstdio>
#include<algorithm>
using namespace std;

int n, m, h;
int hp[1002][1002];
int vp[1002][1002];
int water[1002][1002];

int main()
{
    scanf("%d %d %d", &n, &m, &h);
    for(int i = 0;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            scanf("%d", &hp[i][j]);
            if(hp[i][j] == -1) hp[i][j] = h;
        }
    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = 0;j <= m;j++)
        {
            scanf("%d", &vp[i][j]);
            if(vp[i][j] == -1) vp[i][j] = h;
        }
    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            water[i][j] = h;
        }
    }
    bool change = true;
    while(change)
    {
        change = false;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            int a = water[i][j];
            water[i][j] = min(water[i][j], max(water[i][j - 1], vp[i][j - 1]));
            water[i][j] = min(water[i][j], max(water[i][j + 1], vp[i][j]));
            water[i][j] = min(water[i][j], max(water[i - 1][j], hp[i - 1][j]));
            water[i][j] = min(water[i][j], max(water[i + 1][j], hp[i][j]));
            if(a != water[i][j]) change = true;
        }
    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = m;j > 0;j--)
        {
            int a = water[i][j];
            water[i][j] = min(water[i][j], max(water[i][j - 1], vp[i][j - 1]));
            water[i][j] = min(water[i][j], max(water[i][j + 1], vp[i][j]));
            water[i][j] = min(water[i][j], max(water[i - 1][j], hp[i - 1][j]));
            water[i][j] = min(water[i][j], max(water[i + 1][j], hp[i][j]));
            if(a != water[i][j]) change = true;
        }
    }
    for(int i = n;i > 0;i--)
    {
        for(int j = 1;j <= m;j++)
        {
            int a = water[i][j];
            water[i][j] = min(water[i][j], max(water[i][j - 1], vp[i][j - 1]));
            water[i][j] = min(water[i][j], max(water[i][j + 1], vp[i][j]));
            water[i][j] = min(water[i][j], max(water[i - 1][j], hp[i - 1][j]));
            water[i][j] = min(water[i][j], max(water[i + 1][j], hp[i][j]));
            if(a != water[i][j]) change = true;
        }
    }
    for(int i = n;i > 0;i--)
    {
        for(int j = m;j > 0;j--)
        {
            int a = water[i][j];
            water[i][j] = min(water[i][j], max(water[i][j - 1], vp[i][j - 1]));
            water[i][j] = min(water[i][j], max(water[i][j + 1], vp[i][j]));
            water[i][j] = min(water[i][j], max(water[i - 1][j], hp[i - 1][j]));
            water[i][j] = min(water[i][j], max(water[i + 1][j], hp[i][j]));
            if(a != water[i][j]) change = true;
        }
    }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            ans += water[i][j];
        }
    }
    printf("%d", ans);
    return 0;
}

Compilation message

watertank.cpp: In function 'int main()':
watertank.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &h);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
watertank.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &hp[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
watertank.cpp:25:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &vp[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 14 ms 408 KB Output is correct
5 Correct 2 ms 408 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 1 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 580 KB Output is correct
2 Correct 2 ms 580 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 720 KB Output is correct
6 Correct 2 ms 720 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
8 Correct 2 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 3 ms 720 KB Output is correct
15 Correct 2 ms 720 KB Output is correct
16 Correct 2 ms 720 KB Output is correct
17 Correct 2 ms 720 KB Output is correct
18 Correct 1 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 12284 KB Output is correct
2 Correct 2 ms 12284 KB Output is correct
3 Correct 210 ms 12284 KB Output is correct
4 Correct 273 ms 12284 KB Output is correct
5 Correct 2 ms 12284 KB Output is correct
6 Execution timed out 3035 ms 12424 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12424 KB Output is correct
2 Correct 2 ms 12424 KB Output is correct
3 Correct 2 ms 12424 KB Output is correct
4 Correct 2 ms 12424 KB Output is correct
5 Correct 2 ms 12424 KB Output is correct
6 Correct 2 ms 12424 KB Output is correct
7 Correct 3 ms 12424 KB Output is correct
8 Correct 4 ms 12424 KB Output is correct
9 Correct 2 ms 12424 KB Output is correct
10 Correct 3 ms 12424 KB Output is correct
11 Correct 3 ms 12424 KB Output is correct
12 Correct 2 ms 12424 KB Output is correct
13 Correct 3 ms 12424 KB Output is correct
14 Correct 2 ms 12424 KB Output is correct
15 Correct 2 ms 12424 KB Output is correct
16 Correct 4 ms 12424 KB Output is correct
17 Correct 3 ms 12424 KB Output is correct
18 Correct 3 ms 12424 KB Output is correct
19 Correct 2 ms 12424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 12424 KB Output is correct
2 Correct 2 ms 12424 KB Output is correct
3 Correct 2 ms 12424 KB Output is correct
4 Correct 2 ms 12424 KB Output is correct
5 Correct 2 ms 12424 KB Output is correct
6 Correct 250 ms 12424 KB Output is correct
7 Correct 2 ms 12424 KB Output is correct
8 Correct 2 ms 12424 KB Output is correct
9 Correct 235 ms 12424 KB Output is correct
10 Correct 2 ms 12424 KB Output is correct
11 Correct 2 ms 12424 KB Output is correct
12 Correct 223 ms 12424 KB Output is correct
13 Correct 215 ms 12424 KB Output is correct
14 Correct 2 ms 12424 KB Output is correct
15 Correct 327 ms 12424 KB Output is correct
16 Correct 2 ms 12424 KB Output is correct
17 Correct 2 ms 12424 KB Output is correct
18 Correct 2 ms 12424 KB Output is correct
19 Correct 238 ms 12424 KB Output is correct
20 Correct 3 ms 12424 KB Output is correct
21 Execution timed out 3037 ms 12484 KB Time limit exceeded
22 Halted 0 ms 0 KB -