답안 #505446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
505446 2022-01-11T05:08:27 Z pragmatist Bomb (IZhO17_bomb) C++17
6 / 100
1000 ms 12616 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;
	}
	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 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 6348 KB Output is correct
4 Correct 2 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 1 ms 332 KB Output isn't correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Incorrect 1 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 0 ms 332 KB Output isn't correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Incorrect 3 ms 332 KB Output isn't correct
17 Incorrect 48 ms 588 KB Output isn't correct
18 Incorrect 30 ms 664 KB Output isn't correct
19 Incorrect 165 ms 772 KB Output isn't correct
20 Incorrect 179 ms 760 KB Output isn't correct
21 Incorrect 12 ms 584 KB Output isn't correct
22 Incorrect 50 ms 588 KB Output isn't correct
23 Incorrect 660 ms 796 KB Output isn't correct
24 Incorrect 134 ms 708 KB Output isn't correct
25 Execution timed out 1000 ms 804 KB Time limit exceeded
26 Execution timed out 1098 ms 716 KB Time limit exceeded
27 Execution timed out 1083 ms 1740 KB Time limit exceeded
28 Execution timed out 1078 ms 1652 KB Time limit exceeded
29 Execution timed out 1082 ms 2124 KB Time limit exceeded
30 Execution timed out 1091 ms 2380 KB Time limit exceeded
31 Execution timed out 1067 ms 1868 KB Time limit exceeded
32 Execution timed out 1090 ms 2348 KB Time limit exceeded
33 Execution timed out 1082 ms 2508 KB Time limit exceeded
34 Execution timed out 1049 ms 1996 KB Time limit exceeded
35 Execution timed out 1084 ms 2508 KB Time limit exceeded
36 Execution timed out 1065 ms 2508 KB Time limit exceeded
37 Incorrect 1 ms 332 KB Output isn't correct
38 Execution timed out 1083 ms 12492 KB Time limit exceeded
39 Incorrect 2 ms 332 KB Output isn't correct
40 Execution timed out 1098 ms 4588 KB Time limit exceeded
41 Incorrect 2 ms 332 KB Output isn't correct
42 Execution timed out 1087 ms 716 KB Time limit exceeded
43 Execution timed out 1094 ms 12484 KB Time limit exceeded
44 Execution timed out 1096 ms 2508 KB Time limit exceeded
45 Execution timed out 1086 ms 12416 KB Time limit exceeded
46 Execution timed out 1089 ms 12484 KB Time limit exceeded
47 Execution timed out 1089 ms 12528 KB Time limit exceeded
48 Execution timed out 1093 ms 12484 KB Time limit exceeded
49 Execution timed out 1097 ms 12484 KB Time limit exceeded
50 Execution timed out 1081 ms 12420 KB Time limit exceeded
51 Execution timed out 1084 ms 12456 KB Time limit exceeded
52 Execution timed out 1086 ms 12464 KB Time limit exceeded
53 Execution timed out 1092 ms 12484 KB Time limit exceeded
54 Execution timed out 1098 ms 12468 KB Time limit exceeded
55 Execution timed out 1087 ms 12448 KB Time limit exceeded
56 Execution timed out 1089 ms 12484 KB Time limit exceeded
57 Execution timed out 1096 ms 12436 KB Time limit exceeded
58 Execution timed out 1090 ms 12412 KB Time limit exceeded
59 Execution timed out 1087 ms 12612 KB Time limit exceeded
60 Execution timed out 1089 ms 12484 KB Time limit exceeded
61 Execution timed out 1087 ms 12500 KB Time limit exceeded
62 Execution timed out 1092 ms 12460 KB Time limit exceeded
63 Execution timed out 1083 ms 12456 KB Time limit exceeded
64 Execution timed out 1079 ms 12440 KB Time limit exceeded
65 Execution timed out 1089 ms 12540 KB Time limit exceeded
66 Execution timed out 1085 ms 12504 KB Time limit exceeded
67 Execution timed out 1092 ms 12488 KB Time limit exceeded
68 Execution timed out 1092 ms 12476 KB Time limit exceeded
69 Execution timed out 1099 ms 12512 KB Time limit exceeded
70 Execution timed out 1090 ms 10064 KB Time limit exceeded
71 Execution timed out 1081 ms 12456 KB Time limit exceeded
72 Execution timed out 1093 ms 12484 KB Time limit exceeded
73 Execution timed out 1087 ms 12424 KB Time limit exceeded
74 Execution timed out 1097 ms 12448 KB Time limit exceeded
75 Execution timed out 1098 ms 12480 KB Time limit exceeded
76 Execution timed out 1095 ms 12484 KB Time limit exceeded
77 Execution timed out 1073 ms 12488 KB Time limit exceeded
78 Execution timed out 1100 ms 12452 KB Time limit exceeded
79 Execution timed out 1066 ms 12472 KB Time limit exceeded
80 Execution timed out 1090 ms 12484 KB Time limit exceeded
81 Execution timed out 1089 ms 12484 KB Time limit exceeded
82 Execution timed out 1086 ms 12484 KB Time limit exceeded
83 Execution timed out 1053 ms 12444 KB Time limit exceeded
84 Execution timed out 1078 ms 12508 KB Time limit exceeded
85 Execution timed out 1095 ms 12524 KB Time limit exceeded
86 Execution timed out 1062 ms 12456 KB Time limit exceeded
87 Execution timed out 1087 ms 12484 KB Time limit exceeded
88 Execution timed out 1075 ms 12484 KB Time limit exceeded
89 Execution timed out 1100 ms 12492 KB Time limit exceeded
90 Execution timed out 1097 ms 10052 KB Time limit exceeded
91 Execution timed out 1099 ms 12412 KB Time limit exceeded
92 Execution timed out 1076 ms 12516 KB Time limit exceeded
93 Execution timed out 1088 ms 12484 KB Time limit exceeded
94 Execution timed out 1097 ms 12484 KB Time limit exceeded
95 Execution timed out 1062 ms 12616 KB Time limit exceeded
96 Execution timed out 1095 ms 12476 KB Time limit exceeded
97 Execution timed out 1086 ms 12480 KB Time limit exceeded
98 Execution timed out 1095 ms 12460 KB Time limit exceeded
99 Execution timed out 1090 ms 12468 KB Time limit exceeded
100 Execution timed out 1070 ms 12504 KB Time limit exceeded