답안 #93211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93211 2019-01-07T09:41:58 Z Vardanyan Bomb (IZhO17_bomb) C++14
43 / 100
297 ms 105224 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <vector>
using namespace std;
const int N = 2505;
int dzaxic[N][N];
int ajic[N][N];
int a[N][N];
int n, m;
int M[N];

int mnw = 1000 * 1000 * 1000 + 5;
int mnh = mnw;
vector<pair<int, int> > v;
void calc1(int i, int j,int pl){
	int now = -1;
	for (int ii = i; ii <= n; ii+=pl){
		if (now == -1 || ajic[ii][j] < now){
			now = ajic[ii][j];
		}
		now = min(now, mnw);
	if(pl == 1)	v.push_back({ ii - i + 1, now });
	else v.push_back({ i - ii + 1, now });
	}
}
void calc2(int i, int j,int pl){

}
int main(){
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	}
	for (int i = 1; i <= n; i++)
	{
		int now = 0;
		for (int j = 1; j <= m; j++){
			if (a[i][j]){
				now++;
				dzaxic[i][j] = now;
			}
			else{
			if(now)	mnw = min(mnw, now);
				now = 0;
			}
		}
		if (now)	mnw = min(mnw, now);
		now = 0;
		for (int j = m; j >= 1; j--){
			if (a[i][j]){
				now++;
				ajic[i][j] = now;
			}
			else now = 0;
		}
	}
	for (int j = 1; j <= m; j++){
			int now = 0;
		for (int i = 1; i <= n; i++){
			if (a[i][j]){
				now++;
			}
			else{
			if(now)	mnh = min(mnh, now);
				now = 0;
			}
		}
		if (now)	mnh = min(mnh, now);
	}
	//cout << mnh << " " << mnw << endl;
	/*for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cout <<ajic[i][j] << " ";
		}
		cout << endl;
	}*/
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j - 1] == 0 && a[i - 1][j - 1] == 0){
				int now = -1;
				//calc1(i, j, 1);
				for (int ii = i; ii <= n; ii++){
					if (a[ii][j] == 0) break;
					if (now == -1 || ajic[ii][j] < now){
						now = ajic[ii][j];
					}
					now = min(now, mnw);
					v.push_back({ ii - i + 1, now });
				}
			}
			if (a[i][j] == 1 && a[i][j - 1] == 0 && a[i + 1][j - 1] == 0 && a[i][j + 1] == 0){
				int now = -1;
				//calc1(i, j, -1);
				for (int ii = i; ii >= 1; ii--){
					if (a[ii][j] == 0) break;
					if (now == -1 || ajic[ii][j] < now){
						now = ajic[ii][j];
					}
					now = min(now, mnw);
					v.push_back({ i - ii + 1, now });
				}
			}
			if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j + 1] == 0 && a[i - 1][j + 1] == 0){
				int now = -1;
				for (int ii = i; ii <= n; ii++){
					if (a[ii][j] == 0) break;
					if (now == -1 || dzaxic[i][j] < now){
						now = dzaxic[i][j];
					}
					now = min(now, mnw);
					v.push_back({ ii - i + 1, now });
				}
			}
			if (a[i][j] == 1 && a[i + 1][j] == 0 && a[i][j + 1] == 0 && a[i + 1][j + 1] == 0){
				int now = -1;
				for (int ii = i; ii >= 1; ii--){
					if (a[ii][j] == 0) break;
					if (now == -1 || dzaxic[ii][j] < now){
						now = dzaxic[ii][j];
					}
					now = min(now, mnw);
					v.push_back({ i - ii + 1, now });
				}
			}
		}
	}
	//cout << mnh << " " << mnw << endl;
	memset(M, -1, sizeof M);
	for (int i = 0; i < v.size(); i++){
		int a = v[i].first;
		int b = v[i].second;
		if (M[a] == -1 || M[a] > b){
			M[a] = b;
		}
	}
	long long ans = 0;
	for (int i = 0; i < v.size(); i++){
		long long a = v[i].first;
		if (a > mnh) continue;
		long long b = M[a];
		a *= b;
		ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:51:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(now) mnw = min(mnw, now);
    ^~
bomb.cpp:52:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     now = 0;
     ^~~
bomb.cpp:72:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(now) mnh = min(mnh, now);
    ^~
bomb.cpp:73:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     now = 0;
     ^~~
bomb.cpp:137:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++){
                  ~~^~~~~~~~~~
bomb.cpp:145:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++){
                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 63 ms 47060 KB Output is correct
4 Correct 40 ms 38752 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Incorrect 2 ms 504 KB Output isn't correct
9 Incorrect 2 ms 632 KB Output isn't correct
10 Correct 2 ms 504 KB Output is correct
11 Incorrect 2 ms 632 KB Output isn't correct
12 Incorrect 2 ms 504 KB Output isn't correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Incorrect 2 ms 504 KB Output isn't correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 1144 KB Output is correct
18 Correct 2 ms 1016 KB Output is correct
19 Incorrect 2 ms 1272 KB Output isn't correct
20 Incorrect 3 ms 1272 KB Output isn't correct
21 Correct 2 ms 716 KB Output is correct
22 Correct 2 ms 1016 KB Output is correct
23 Incorrect 3 ms 1272 KB Output isn't correct
24 Incorrect 2 ms 1272 KB Output isn't correct
25 Incorrect 3 ms 1528 KB Output isn't correct
26 Correct 3 ms 1656 KB Output is correct
27 Correct 6 ms 4936 KB Output is correct
28 Incorrect 5 ms 2424 KB Output isn't correct
29 Incorrect 10 ms 7032 KB Output isn't correct
30 Incorrect 9 ms 5880 KB Output isn't correct
31 Incorrect 7 ms 4344 KB Output isn't correct
32 Incorrect 8 ms 5496 KB Output isn't correct
33 Incorrect 10 ms 6904 KB Output isn't correct
34 Incorrect 5 ms 2680 KB Output isn't correct
35 Incorrect 8 ms 3704 KB Output isn't correct
36 Correct 12 ms 8312 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 199 ms 76180 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Incorrect 34 ms 20860 KB Output isn't correct
41 Correct 2 ms 632 KB Output is correct
42 Correct 3 ms 1656 KB Output is correct
43 Correct 297 ms 105224 KB Output is correct
44 Correct 11 ms 8312 KB Output is correct
45 Correct 275 ms 90064 KB Output is correct
46 Correct 218 ms 76320 KB Output is correct
47 Correct 283 ms 90104 KB Output is correct
48 Correct 237 ms 80364 KB Output is correct
49 Correct 217 ms 76024 KB Output is correct
50 Incorrect 246 ms 79884 KB Output isn't correct
51 Incorrect 233 ms 79960 KB Output isn't correct
52 Correct 226 ms 79848 KB Output is correct
53 Incorrect 241 ms 79208 KB Output isn't correct
54 Correct 226 ms 64592 KB Output is correct
55 Incorrect 234 ms 62704 KB Output isn't correct
56 Correct 225 ms 79664 KB Output is correct
57 Incorrect 192 ms 56432 KB Output isn't correct
58 Correct 204 ms 62448 KB Output is correct
59 Correct 203 ms 58248 KB Output is correct
60 Correct 199 ms 67168 KB Output is correct
61 Correct 204 ms 75176 KB Output is correct
62 Correct 225 ms 75272 KB Output is correct
63 Correct 200 ms 75180 KB Output is correct
64 Correct 193 ms 58232 KB Output is correct
65 Correct 231 ms 78068 KB Output is correct
66 Incorrect 208 ms 71160 KB Output isn't correct
67 Correct 220 ms 79408 KB Output is correct
68 Incorrect 245 ms 79364 KB Output isn't correct
69 Correct 200 ms 55424 KB Output is correct
70 Incorrect 119 ms 31196 KB Output isn't correct
71 Incorrect 191 ms 47376 KB Output isn't correct
72 Incorrect 187 ms 52088 KB Output isn't correct
73 Incorrect 203 ms 52640 KB Output isn't correct
74 Incorrect 203 ms 55508 KB Output isn't correct
75 Incorrect 199 ms 56844 KB Output isn't correct
76 Incorrect 191 ms 58076 KB Output isn't correct
77 Incorrect 195 ms 58696 KB Output isn't correct
78 Incorrect 199 ms 58872 KB Output isn't correct
79 Incorrect 175 ms 31092 KB Output isn't correct
80 Incorrect 179 ms 32504 KB Output isn't correct
81 Incorrect 191 ms 32916 KB Output isn't correct
82 Incorrect 218 ms 61252 KB Output isn't correct
83 Incorrect 219 ms 61504 KB Output isn't correct
84 Incorrect 195 ms 26496 KB Output isn't correct
85 Incorrect 210 ms 60392 KB Output isn't correct
86 Incorrect 222 ms 73720 KB Output isn't correct
87 Incorrect 215 ms 59068 KB Output isn't correct
88 Incorrect 222 ms 59896 KB Output isn't correct
89 Incorrect 222 ms 68616 KB Output isn't correct
90 Incorrect 135 ms 44792 KB Output isn't correct
91 Incorrect 219 ms 63524 KB Output isn't correct
92 Incorrect 222 ms 65204 KB Output isn't correct
93 Incorrect 224 ms 72404 KB Output isn't correct
94 Incorrect 216 ms 66992 KB Output isn't correct
95 Incorrect 223 ms 60904 KB Output isn't correct
96 Incorrect 221 ms 60564 KB Output isn't correct
97 Incorrect 217 ms 73112 KB Output isn't correct
98 Incorrect 224 ms 60460 KB Output isn't correct
99 Incorrect 209 ms 66572 KB Output isn't correct
100 Incorrect 217 ms 72064 KB Output isn't correct