# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
594129 | 2022-07-12T06:48:32 Z | 장태환(#8433) | Sandcastle 2 (JOI22_ho_t5) | C++17 | 3365 ms | 16848 KB |
#include <bits/stdc++.h> #pragma GCC optimization ("Ofast") #pragma GCC optimization ("unroll-loops") using namespace std; vector<vector<int>>x; vector<vector<vector<int>>>val; vector<vector<vector<int>>>psum; signed main() { int N, M; ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N >> M; int sw = 0; int i, j; for (i = 0; i < N; i++) { vector<int>y; for (j = 0; j < M; j++) { int a; cin >> a; y.push_back(a); } x.push_back(y); } if (N > M) { vector<vector<int>>t; int i, j; for (i = 0; i < M; i++) { vector<int>y; for (j = 0; j < N; j++) { y.push_back(x[j][i]); } t.push_back(y); } x = t; swap(N, M); } for (i = 0; i < N; i++) { vector<vector<int>>te; for (j = 0; j < M; j++) { vector<int>t; int k; for (k = 0; k < 16; k++) { vector<int>t3; if ((k & 1)&&i) { t3.push_back(x[i - 1][j]); } if ((k & 2) && j) { t3.push_back(x[i][j-1]); } if ((k & 4) && i!=N-1) { t3.push_back(x[i+1][j]); } if ((k & 8) && j != M - 1) { t3.push_back(x[i][j+1]); } sort(t3.begin(), t3.end()); int l; int ll = 0; int u = 0; for (l = 0; l < t3.size(); l++) { if (t3[l] < x[i][j]) ll = t3[l]; else { u = 1; break; } } if (!u) { t.push_back((1 << 24) - ll); } else { t.push_back(x[i][j] - ll); } } te.push_back(t); } val.push_back(te); psum.push_back(te); } for (i = 0; i < N; i++) { for (j = 0; j < M; j++) { int k; for (k = 0; k < 16; k++) { if(i) psum[i][j][k] += psum[i - 1][j][k]; } } } int ans = N*M; for (i = 0; i < N; i++) { for (j = i + 1; j < N; j++) { int k; for (k = 0; k < M; k++) { int v = val[j][k][9] + val[i][k][12]; v += psum[j - 1][k][13]-psum[i][k][13]; int l; for (l = k + 1; l < M; l++) { if (v + val[j][l][3] + val[i][l][6] + psum[j - 1][l][7] - psum[i][l][7]==(1<<24)) { ans++; } v += val[i][l][14]+val[j][l][11]; v += -psum[i][l][15] + psum[j-1][l][15]; } } } } for (i = 0; i < N; i++) { int k; for (k = 0; k < M; k++) { int v = val[i][k][8]; int l; for (l = k + 1; l < M; l++) { if (v + val[i][l][2] == (1 << 24)) { ans++; } v += val[i][l][10]; } } } for (i = 0; i < M; i++) { int k; for (k = 0; k < N; k++) { int v = val[k][i][4]; int l; for (l = k + 1; l < N; l++) { if (v + val[l][i][1] == (1 << 24)) { ans++; } v += val[l][i][5]; } } } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2322 ms | 15668 KB | Output is correct |
3 | Correct | 2122 ms | 15624 KB | Output is correct |
4 | Correct | 2212 ms | 15824 KB | Output is correct |
5 | Correct | 2223 ms | 15780 KB | Output is correct |
6 | Correct | 2402 ms | 15888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 724 KB | Output is correct |
8 | Correct | 4 ms | 724 KB | Output is correct |
9 | Correct | 5 ms | 640 KB | Output is correct |
10 | Correct | 5 ms | 596 KB | Output is correct |
11 | Correct | 5 ms | 720 KB | Output is correct |
12 | Correct | 8 ms | 724 KB | Output is correct |
13 | Correct | 8 ms | 560 KB | Output is correct |
14 | Correct | 4 ms | 468 KB | Output is correct |
15 | Correct | 7 ms | 552 KB | Output is correct |
16 | Correct | 6 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 724 KB | Output is correct |
8 | Correct | 4 ms | 724 KB | Output is correct |
9 | Correct | 5 ms | 640 KB | Output is correct |
10 | Correct | 5 ms | 596 KB | Output is correct |
11 | Correct | 5 ms | 720 KB | Output is correct |
12 | Correct | 8 ms | 724 KB | Output is correct |
13 | Correct | 8 ms | 560 KB | Output is correct |
14 | Correct | 4 ms | 468 KB | Output is correct |
15 | Correct | 7 ms | 552 KB | Output is correct |
16 | Correct | 6 ms | 596 KB | Output is correct |
17 | Correct | 54 ms | 2572 KB | Output is correct |
18 | Correct | 65 ms | 1788 KB | Output is correct |
19 | Correct | 92 ms | 1820 KB | Output is correct |
20 | Correct | 71 ms | 1776 KB | Output is correct |
21 | Correct | 50 ms | 1748 KB | Output is correct |
22 | Correct | 51 ms | 1748 KB | Output is correct |
23 | Correct | 46 ms | 1728 KB | Output is correct |
24 | Correct | 42 ms | 1620 KB | Output is correct |
25 | Correct | 58 ms | 1780 KB | Output is correct |
26 | Correct | 59 ms | 1748 KB | Output is correct |
27 | Correct | 112 ms | 1680 KB | Output is correct |
28 | Correct | 53 ms | 1780 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 4 ms | 724 KB | Output is correct |
8 | Correct | 4 ms | 724 KB | Output is correct |
9 | Correct | 5 ms | 640 KB | Output is correct |
10 | Correct | 5 ms | 596 KB | Output is correct |
11 | Correct | 5 ms | 720 KB | Output is correct |
12 | Correct | 8 ms | 724 KB | Output is correct |
13 | Correct | 8 ms | 560 KB | Output is correct |
14 | Correct | 4 ms | 468 KB | Output is correct |
15 | Correct | 7 ms | 552 KB | Output is correct |
16 | Correct | 6 ms | 596 KB | Output is correct |
17 | Correct | 54 ms | 2572 KB | Output is correct |
18 | Correct | 65 ms | 1788 KB | Output is correct |
19 | Correct | 92 ms | 1820 KB | Output is correct |
20 | Correct | 71 ms | 1776 KB | Output is correct |
21 | Correct | 50 ms | 1748 KB | Output is correct |
22 | Correct | 51 ms | 1748 KB | Output is correct |
23 | Correct | 46 ms | 1728 KB | Output is correct |
24 | Correct | 42 ms | 1620 KB | Output is correct |
25 | Correct | 58 ms | 1780 KB | Output is correct |
26 | Correct | 59 ms | 1748 KB | Output is correct |
27 | Correct | 112 ms | 1680 KB | Output is correct |
28 | Correct | 53 ms | 1780 KB | Output is correct |
29 | Correct | 3052 ms | 16848 KB | Output is correct |
30 | Correct | 3365 ms | 10944 KB | Output is correct |
31 | Correct | 3156 ms | 11124 KB | Output is correct |
32 | Correct | 3054 ms | 13632 KB | Output is correct |
33 | Correct | 2924 ms | 11068 KB | Output is correct |
34 | Correct | 3114 ms | 11052 KB | Output is correct |
35 | Correct | 1402 ms | 7368 KB | Output is correct |
36 | Correct | 3027 ms | 10916 KB | Output is correct |
37 | Correct | 2976 ms | 10964 KB | Output is correct |
38 | Correct | 3109 ms | 10988 KB | Output is correct |
39 | Correct | 3359 ms | 10968 KB | Output is correct |
40 | Correct | 2944 ms | 10992 KB | Output is correct |
41 | Incorrect | 3215 ms | 10972 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |