Submission #1693039
Source Code Expand
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int MAX_N = 105; int f[MAX_N][MAX_N][MAX_N], g[MAX_N][MAX_N][MAX_N]; int H, W, A[MAX_N][MAX_N], eX, eY; inline void update(int &x, int y) { if (x < y) x = y; } inline int get_num(int a, int b, int c, int d) { if (a > c || b > d) return 0; return A[c][d] - A[a - 1][d] - A[c][b - 1] + A[a - 1][b - 1]; } int main() { scanf("%d%d", &H, &W); for (int i = 1; i <= H; ++i) { static char S[MAX_N]; scanf("%s", S + 1); for (int j = 1; j <= W; ++j) { A[i][j] = A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1] + (S[j] == 'o'); if (S[j] == 'E') eX = i, eY = j; } } f[0][0][0] = 0; int res = 0; for (int i = 0; i < H; ++i) { memset(g, 0, sizeof g); for (int j = 0; j + i <= H; ++j) for (int k = 0; k < W; ++k) for (int m = 0; m + k <= W; ++m) { res = max(res, f[j][k][m]); int U = i + 1, D = H - j, L = k + 1, R = W - m; int u = eX - j, d = eX + i, l = eY - m, r = eY + k; if (U > D || L > R) continue; if (d + 1 <= D && d + 1 >= U) update(g[j][k][m], f[j][k][m] + get_num(d + 1, max(L, l), d + 1, min(R, r))); if (u - 1 >= U && u - 1 <= D) update(f[j + 1][k][m], f[j][k][m] + get_num(u - 1, max(L, l), u - 1, min(R, r))); if (r + 1 <= R && r + 1 >= L) update(f[j][k + 1][m], f[j][k][m] + get_num(max(U, u), r + 1, min(D, d), r + 1)); if (l - 1 >= L && l - 1 <= R) update(f[j][k][m + 1], f[j][k][m] + get_num(max(U, u), l - 1, min(D, d), l - 1)); } memcpy(f, g, sizeof f); } printf("%d\n" , res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Salvage Robots |
User | kiiiiii |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1632 Byte |
Status | AC |
Exec Time | 329 ms |
Memory | 9344 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:21:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &H, &W); ^ ./Main.cpp:24:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", S + 1); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1400 / 1400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt, 1_64.txt, 1_65.txt, 1_66.txt, 1_67.txt, 1_68.txt, 1_69.txt, 1_70.txt, 1_71.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 5 ms | 9216 KB |
0_01.txt | AC | 4 ms | 9216 KB |
0_02.txt | AC | 5 ms | 9216 KB |
0_03.txt | AC | 6 ms | 9216 KB |
1_00.txt | AC | 4 ms | 9216 KB |
1_01.txt | AC | 4 ms | 9216 KB |
1_02.txt | AC | 4 ms | 9216 KB |
1_03.txt | AC | 4 ms | 9216 KB |
1_04.txt | AC | 324 ms | 9216 KB |
1_05.txt | AC | 329 ms | 9216 KB |
1_06.txt | AC | 302 ms | 9216 KB |
1_07.txt | AC | 318 ms | 9216 KB |
1_08.txt | AC | 210 ms | 9216 KB |
1_09.txt | AC | 221 ms | 9216 KB |
1_10.txt | AC | 298 ms | 9216 KB |
1_11.txt | AC | 230 ms | 9216 KB |
1_12.txt | AC | 228 ms | 9216 KB |
1_13.txt | AC | 151 ms | 9216 KB |
1_14.txt | AC | 226 ms | 9216 KB |
1_15.txt | AC | 264 ms | 9216 KB |
1_16.txt | AC | 182 ms | 9216 KB |
1_17.txt | AC | 229 ms | 9216 KB |
1_18.txt | AC | 266 ms | 9216 KB |
1_19.txt | AC | 217 ms | 9216 KB |
1_20.txt | AC | 197 ms | 9216 KB |
1_21.txt | AC | 244 ms | 9216 KB |
1_22.txt | AC | 245 ms | 9216 KB |
1_23.txt | AC | 225 ms | 9216 KB |
1_24.txt | AC | 266 ms | 9216 KB |
1_25.txt | AC | 254 ms | 9216 KB |
1_26.txt | AC | 263 ms | 9216 KB |
1_27.txt | AC | 295 ms | 9216 KB |
1_28.txt | AC | 216 ms | 9216 KB |
1_29.txt | AC | 252 ms | 9216 KB |
1_30.txt | AC | 188 ms | 9216 KB |
1_31.txt | AC | 257 ms | 9216 KB |
1_32.txt | AC | 240 ms | 9216 KB |
1_33.txt | AC | 261 ms | 9216 KB |
1_34.txt | AC | 296 ms | 9216 KB |
1_35.txt | AC | 283 ms | 9216 KB |
1_36.txt | AC | 304 ms | 9344 KB |
1_37.txt | AC | 281 ms | 9216 KB |
1_38.txt | AC | 271 ms | 9216 KB |
1_39.txt | AC | 254 ms | 9216 KB |
1_40.txt | AC | 249 ms | 9344 KB |
1_41.txt | AC | 230 ms | 9216 KB |
1_42.txt | AC | 182 ms | 9216 KB |
1_43.txt | AC | 210 ms | 9216 KB |
1_44.txt | AC | 199 ms | 9216 KB |
1_45.txt | AC | 221 ms | 9216 KB |
1_46.txt | AC | 245 ms | 9216 KB |
1_47.txt | AC | 212 ms | 9216 KB |
1_48.txt | AC | 213 ms | 9216 KB |
1_49.txt | AC | 234 ms | 9216 KB |
1_50.txt | AC | 198 ms | 9216 KB |
1_51.txt | AC | 216 ms | 9216 KB |
1_52.txt | AC | 216 ms | 9216 KB |
1_53.txt | AC | 235 ms | 9216 KB |
1_54.txt | AC | 232 ms | 9216 KB |
1_55.txt | AC | 213 ms | 9216 KB |
1_56.txt | AC | 240 ms | 9216 KB |
1_57.txt | AC | 239 ms | 9216 KB |
1_58.txt | AC | 252 ms | 9216 KB |
1_59.txt | AC | 215 ms | 9216 KB |
1_60.txt | AC | 247 ms | 9216 KB |
1_61.txt | AC | 177 ms | 9216 KB |
1_62.txt | AC | 255 ms | 9216 KB |
1_63.txt | AC | 220 ms | 9216 KB |
1_64.txt | AC | 148 ms | 9216 KB |
1_65.txt | AC | 218 ms | 9216 KB |
1_66.txt | AC | 217 ms | 9216 KB |
1_67.txt | AC | 192 ms | 9216 KB |
1_68.txt | AC | 227 ms | 9216 KB |
1_69.txt | AC | 185 ms | 9216 KB |
1_70.txt | AC | 222 ms | 9216 KB |
1_71.txt | AC | 214 ms | 9216 KB |