Submission #17460

#TimeUsernameProblemLanguageResultExecution timeMemory
17460azecoderUFO (IZhO14_ufo)C++98
0 / 100
0 ms2016 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...