# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28301 | 2017-07-16T04:32:06 Z | 뚜룹뚜룹뚜룹뚜스~><(#1151, chan492811) | Oriental P.A.D.A.K (FXCUP2_padak) | C++11 | 436 ms | 17904 KB |
#include <cstdio> #include <cstring> #include <deque> using namespace std; int n, m, k, b, z, r1, r2; int direct[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int darr[1000010], rarr1[1000010], rarr2[1000010]; deque <int> dq; int main(){ int i, a, s, x, y, now, nz, tmp; scanf("%d %d %d %d %d", &n, &m, &k, &b, &z); memset(darr, -1, sizeof(darr)); for(i = 0; i < k; i++){ scanf("%d %d", &a, &s); a--; s--; dq.push_back(a * m + s); darr[a * m + s] = 0; rarr1[0]++; } while(!dq.empty()){ a = dq[0] / m; s = dq[0] % m; dq.pop_front(); for(i = 0; i < 4; i++){ x = a + direct[i][0]; y = s + direct[i][1]; if(x < 0 || x >= n || y < 0 || y >= m) continue; if(darr[x * m + y] != -1) continue; darr[x * m + y] = darr[a * m + s] + 1; rarr1[darr[x * m + y]]++; dq.push_back(x * m + y); } } for(i = 1; i <= n * m; i++) rarr2[i] = rarr1[i]; now = 1; for(i = 1; i <= n * m; i++){ now = max(now, i); if(now > n * m) break; nz = z; while(nz){ if(now > n * m) break; if(rarr1[now] >= nz) rarr1[now] -= nz, r1 += nz, nz = 0; else r1 += rarr1[now], nz -= rarr1[now++]; } } now = n * m; while(rarr2[now] == 0) now--; for(i = 1; i <= n * m; i++){ if(now < i) break; nz = z; while(nz){ if(now < i) break; if(rarr2[now] >= nz) rarr2[now] -= nz, r2 += nz, nz = 0; else r2 += rarr2[now], nz -= rarr2[now--]; } } printf("%d %d", r2, r1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13648 KB | Output is correct |
2 | Correct | 0 ms | 13648 KB | Output is correct |
3 | Correct | 36 ms | 13648 KB | Output is correct |
4 | Correct | 36 ms | 13648 KB | Output is correct |
5 | Correct | 36 ms | 13648 KB | Output is correct |
6 | Correct | 29 ms | 13648 KB | Output is correct |
7 | Correct | 43 ms | 13648 KB | Output is correct |
8 | Correct | 36 ms | 13648 KB | Output is correct |
9 | Correct | 29 ms | 13648 KB | Output is correct |
10 | Correct | 36 ms | 13648 KB | Output is correct |
11 | Correct | 59 ms | 13780 KB | Output is correct |
12 | Correct | 36 ms | 13648 KB | Output is correct |
13 | Correct | 33 ms | 13648 KB | Output is correct |
14 | Correct | 39 ms | 13648 KB | Output is correct |
15 | Correct | 33 ms | 13648 KB | Output is correct |
16 | Correct | 36 ms | 13648 KB | Output is correct |
17 | Correct | 56 ms | 13780 KB | Output is correct |
18 | Correct | 59 ms | 14052 KB | Output is correct |
19 | Correct | 46 ms | 13780 KB | Output is correct |
20 | Correct | 39 ms | 13780 KB | Output is correct |
21 | Correct | 66 ms | 14176 KB | Output is correct |
22 | Correct | 39 ms | 13648 KB | Output is correct |
23 | Correct | 43 ms | 13648 KB | Output is correct |
24 | Correct | 419 ms | 17904 KB | Output is correct |
25 | Correct | 436 ms | 17904 KB | Output is correct |
26 | Correct | 389 ms | 17904 KB | Output is correct |
27 | Correct | 419 ms | 17904 KB | Output is correct |
28 | Correct | 406 ms | 17904 KB | Output is correct |
29 | Correct | 399 ms | 17772 KB | Output is correct |
30 | Correct | 426 ms | 17904 KB | Output is correct |
31 | Correct | 33 ms | 13648 KB | Output is correct |
32 | Correct | 29 ms | 13648 KB | Output is correct |