답안 #505449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
505449 2022-01-11T05:09:10 Z pragmatist Bomb (IZhO17_bomb) C++17
6 / 100
112 ms 6444 KB
#include <bits/stdc++.h>                            
 
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
 
using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;

const int N = (int)1e6 + 7;
const int M = (int)5e6 + 7;
const ll MOD = (ll)1e9 + 7;                    
const int inf = (int)1e9 + 7;
const ll INF = (ll)3e18 + 7;

pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}};

int n, m;
char c[2501][2501];
bool used[2501][2501];

void solve() {           
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			cin >> c[i][j];
		}
	}
	int ans = inf;
	if(n == 1) {
		int cur = 0;
		for(int i = 1; i <= m; ++i) {
			if(c[1][i] == '1') cur++;
			else {
				if(cur > 0) ans = min(ans, cur);
				cur = 0;
			}
		}
		if(c[1][m] == '1') ans = min(ans, cur);
		cout << ans << nl;		
		return;
	}
	if(m == 1) {
		int cur = 0;
		for(int i = 1; i <= n; ++i) {
			if(c[i][1] == '1') cur++;
			else {
				if(cur > 0) ans = min(ans, cur);
				cur = 0;
			}
		}                                      		
		if(c[n][1] == '1') ans = min(ans, cur);
		cout << ans << nl;		
		return;
	}
	if(n > 50 || m > 50) return;
	for(int e = 1; e <= n; ++e) {
		for(int f = 1; f <= n; ++f) {
			bool ok = 1;
			for(int i = 1; i <= n; ++i) fill(used[i] + 1, used[i] + 1 + m, 0);
			for(int i = 1; i <= n; ++i) {
				for(int j = 1; j <= n; ++j) {
			        if(i + e - 1 > n || j + f - 1 > m) continue;
					if(c[i][j] == '1') {
						bool cur = 1;
						for(int ii = i; ii <= i + e - 1 && cur; ++ii) {
							for(int jj = j; jj <= j + f - 1 && cur; ++jj) {
								cur &= (c[ii][jj] == '1');
							}
						}
						if(cur) {
							for(int ii = i; ii <= i + e - 1 && cur; ++ii) {
								for(int jj = j; jj <= j + f - 1 && cur; ++jj) {
									used[ii][jj] = 1;
								}
							}	
						}					
					}
				}
			}
			for(int i = 1; i <= n && ok; ++i) {
				for(int j = 1; j <= n && ok; ++j) {
					if(c[i][j] == '1') ok &= (used[i][j] == 1);
				}
			}
			if(ok) {
				ans = max(ans, e * f);
				//cout << e << ' ' << f << nl;
			}
		}
	}
	cout << ans << nl;
}
                
signed main() {                   
	ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
   	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; ++i) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 3 ms 6436 KB Output is correct
4 Correct 3 ms 6348 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 332 KB Output isn't correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Incorrect 2 ms 332 KB Output isn't correct
10 Incorrect 0 ms 332 KB Output isn't correct
11 Incorrect 1 ms 332 KB Output isn't correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Incorrect 1 ms 332 KB Output isn't correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Incorrect 1 ms 408 KB Output isn't correct
16 Incorrect 5 ms 332 KB Output isn't correct
17 Incorrect 0 ms 460 KB Output isn't correct
18 Incorrect 1 ms 460 KB Output isn't correct
19 Incorrect 1 ms 460 KB Output isn't correct
20 Incorrect 1 ms 460 KB Output isn't correct
21 Incorrect 0 ms 332 KB Output isn't correct
22 Incorrect 1 ms 460 KB Output isn't correct
23 Incorrect 0 ms 460 KB Output isn't correct
24 Incorrect 1 ms 460 KB Output isn't correct
25 Incorrect 1 ms 460 KB Output isn't correct
26 Incorrect 0 ms 460 KB Output isn't correct
27 Incorrect 2 ms 972 KB Output isn't correct
28 Incorrect 2 ms 972 KB Output isn't correct
29 Incorrect 2 ms 1228 KB Output isn't correct
30 Incorrect 3 ms 1356 KB Output isn't correct
31 Incorrect 3 ms 1100 KB Output isn't correct
32 Incorrect 3 ms 1228 KB Output isn't correct
33 Incorrect 3 ms 1356 KB Output isn't correct
34 Incorrect 2 ms 1100 KB Output isn't correct
35 Incorrect 3 ms 1356 KB Output isn't correct
36 Incorrect 4 ms 1356 KB Output isn't correct
37 Incorrect 1 ms 332 KB Output isn't correct
38 Incorrect 77 ms 6360 KB Output isn't correct
39 Incorrect 3 ms 332 KB Output isn't correct
40 Incorrect 11 ms 2400 KB Output isn't correct
41 Incorrect 1 ms 332 KB Output isn't correct
42 Incorrect 0 ms 460 KB Output isn't correct
43 Incorrect 82 ms 6304 KB Output isn't correct
44 Incorrect 3 ms 1356 KB Output isn't correct
45 Incorrect 83 ms 6328 KB Output isn't correct
46 Incorrect 85 ms 6284 KB Output isn't correct
47 Incorrect 79 ms 6408 KB Output isn't correct
48 Incorrect 79 ms 6292 KB Output isn't correct
49 Incorrect 80 ms 6416 KB Output isn't correct
50 Incorrect 85 ms 6292 KB Output isn't correct
51 Incorrect 82 ms 6376 KB Output isn't correct
52 Incorrect 83 ms 6292 KB Output isn't correct
53 Incorrect 77 ms 6300 KB Output isn't correct
54 Incorrect 81 ms 6332 KB Output isn't correct
55 Incorrect 80 ms 6356 KB Output isn't correct
56 Incorrect 82 ms 6348 KB Output isn't correct
57 Incorrect 87 ms 6304 KB Output isn't correct
58 Incorrect 82 ms 6444 KB Output isn't correct
59 Incorrect 78 ms 6332 KB Output isn't correct
60 Incorrect 80 ms 6300 KB Output isn't correct
61 Incorrect 81 ms 6336 KB Output isn't correct
62 Incorrect 76 ms 6360 KB Output isn't correct
63 Incorrect 81 ms 6352 KB Output isn't correct
64 Incorrect 90 ms 6300 KB Output isn't correct
65 Incorrect 85 ms 6348 KB Output isn't correct
66 Incorrect 83 ms 6312 KB Output isn't correct
67 Incorrect 82 ms 6344 KB Output isn't correct
68 Incorrect 78 ms 6340 KB Output isn't correct
69 Incorrect 82 ms 6308 KB Output isn't correct
70 Incorrect 65 ms 5128 KB Output isn't correct
71 Incorrect 78 ms 6352 KB Output isn't correct
72 Incorrect 80 ms 6388 KB Output isn't correct
73 Incorrect 83 ms 6368 KB Output isn't correct
74 Incorrect 81 ms 6400 KB Output isn't correct
75 Incorrect 80 ms 6360 KB Output isn't correct
76 Incorrect 78 ms 6360 KB Output isn't correct
77 Incorrect 79 ms 6328 KB Output isn't correct
78 Incorrect 78 ms 6396 KB Output isn't correct
79 Incorrect 79 ms 6296 KB Output isn't correct
80 Incorrect 78 ms 6320 KB Output isn't correct
81 Incorrect 77 ms 6376 KB Output isn't correct
82 Incorrect 83 ms 6308 KB Output isn't correct
83 Incorrect 84 ms 6408 KB Output isn't correct
84 Incorrect 84 ms 6380 KB Output isn't correct
85 Incorrect 112 ms 6380 KB Output isn't correct
86 Incorrect 78 ms 6340 KB Output isn't correct
87 Incorrect 79 ms 6336 KB Output isn't correct
88 Incorrect 78 ms 6368 KB Output isn't correct
89 Incorrect 85 ms 6380 KB Output isn't correct
90 Incorrect 63 ms 5192 KB Output isn't correct
91 Incorrect 96 ms 6364 KB Output isn't correct
92 Incorrect 95 ms 6380 KB Output isn't correct
93 Incorrect 84 ms 6304 KB Output isn't correct
94 Incorrect 78 ms 6344 KB Output isn't correct
95 Incorrect 83 ms 6332 KB Output isn't correct
96 Incorrect 80 ms 6340 KB Output isn't correct
97 Incorrect 81 ms 6332 KB Output isn't correct
98 Incorrect 87 ms 6404 KB Output isn't correct
99 Incorrect 80 ms 6400 KB Output isn't correct
100 Incorrect 85 ms 6384 KB Output isn't correct