Submission #17460

# Submission time Handle Problem Language Result Execution time Memory
17460 2015-12-13T17:11:24 Z azecoder UFO (IZhO14_ufo) C++
0 / 100
0 ms 2016 KB
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <queue>
#include <cmath>
#include <map>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000
#define MOD 1000000
 
using namespace std;
 
int N, M, R, K, P, x, h, ans;
char ch;
 
int main()
{
    freopen("ufo.in", "r", stdin);
    freopen("ufo.out", "w", stdout);
 
    scanf("%d %d %d %d %d", &N, &M, &R, &K, &P);
    int a[N + 1][M + 1];
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= M; j++)
            scanf("%d", &a[i][j]);
    int k = K;
    while (k--) {
        scanf(" %c %d %d", &ch, &x, &h);
        int r = R;
        if (ch == 'N') for (int i = 1; i <= N; i++) if (r && a[i][x] >= h) a[i][x]--, r--;
                                                    else if (!r) break;
        if (ch == 'W') for (int i = 1; i <= M; i++) if (r && a[x][i] >= h) a[x][i]--, r--;
                                                    else if (!r) break;
        if (ch == 'E') for (int i = M; i >= 1; i--) if (r && a[x][i] >= h) a[x][i]--, r--;
                                                    else if (!r) break;
        if (ch == 'S') for (int i = N; i >= 1; i--) if (r && a[i][x] >= h) a[i][x]--, r--;
                                                    else if (!r) break;
    }
    for (int i = 1; i <= N - P + 1; i++)
        for (int j = 1; j <= M - P + 1; j++) {
            int c = 0;
            for (int k = i; k < i + P; k++)
                for (int l = j; l < j + P; l++)
                    c += a[k][l];
            ans = max(ans, c);
        }
    cout << ans << endl;
 
    return 0;
}

Compilation message

ufo.cpp: In function 'int main()':
ufo.cpp:23:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("ufo.in", "r", stdin);
                                  ^
ufo.cpp:24:36: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("ufo.out", "w", stdout);
                                    ^
ufo.cpp:26:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d %d", &N, &M, &R, &K, &P);
                                                ^
ufo.cpp:30:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i][j]);
                                  ^
ufo.cpp:33:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c %d %d", &ch, &x, &h);
                                        ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
3 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
4 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
5 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
6 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
7 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
8 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
9 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
10 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
11 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
12 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
13 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
14 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
15 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
16 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
17 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
18 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
19 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
20 Runtime error 0 ms 2016 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)