Submission #168966

# Submission time Handle Problem Language Result Execution time Memory
168966 2019-12-17T10:26:06 Z abil Bomb (IZhO17_bomb) C++14
10 / 100
1000 ms 105712 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (2500 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

char a[N][N];
int up[N][N], down[N][N], leftt[N][N], rightt[N][N];

int n, m;
bool solve(int x,int y){
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			if(a[i][j] == '1'){
				if(up[i][j] + down[i][j] - 1 < x || leftt[i][j] + rightt[i][j] - 1 < y){
					return false;
				}
			}
		}
	}
	return true;
}

bool check(int x){
	bool f = false;
	for(int i = 1;i * i <= x; i++){
		if(x % i == 0){
			if(solve(x / i, i) || solve(i, x / i)){
				f = true;
				break;
			}
		}
	}
	return f;
}
main()
{
	cin >> n >> m;
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1;i <= n; i++){
		int cnt = 0;
		for(int j = 1;j <= m; j++){
			cnt = (a[i][j] == '0' ? 0 : cnt + 1);
			leftt[i][j] = cnt;
		}
	}
	for(int i = 1;i <= n; i++){
		int cnt = 0;
		for(int j = m;j >= 1; j--){
			cnt = (a[i][j] == '0' ? 0 : cnt + 1);
			rightt[i][j] = cnt;
		}
	}
	for(int i = 1;i <= m; i++){
		int cnt = 0;
		for(int j = 1;j <= n; j++){
			cnt = (a[j][i] == '0' ? 0 : cnt + 1);
			up[j][i] = cnt;
		}
	}
	for(int i = 1;i <= m; i++){
		int cnt = 0;
		for(int j = n;j >= 1; j--){
			cnt = (a[j][i] == '0' ? 0 : cnt + 1);
			down[j][i] = cnt;
		}
	}
	int l = 1, r = n * m; 
	while(r - l > 1){
		int mid = (r + l) >> 1;
		if(check(mid)){
			l = mid;
		}
		else{
			r = mid;
		}
	}
	if(check(r)){
		 l = r;
	}
	cout << l;
}

Compilation message

bomb.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 38 ms 46712 KB Output is correct
4 Correct 45 ms 46584 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 760 KB Output isn't correct
9 Incorrect 2 ms 760 KB Output isn't correct
10 Incorrect 2 ms 632 KB Output isn't correct
11 Incorrect 2 ms 760 KB Output isn't correct
12 Incorrect 2 ms 632 KB Output isn't correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Incorrect 2 ms 760 KB Output isn't correct
16 Incorrect 2 ms 760 KB Output isn't correct
17 Incorrect 4 ms 1656 KB Output isn't correct
18 Incorrect 3 ms 1656 KB Output isn't correct
19 Incorrect 4 ms 2168 KB Output isn't correct
20 Incorrect 4 ms 2168 KB Output isn't correct
21 Incorrect 3 ms 1432 KB Output isn't correct
22 Incorrect 4 ms 1912 KB Output isn't correct
23 Incorrect 5 ms 2424 KB Output isn't correct
24 Incorrect 4 ms 1916 KB Output isn't correct
25 Incorrect 4 ms 2296 KB Output isn't correct
26 Incorrect 5 ms 2296 KB Output isn't correct
27 Correct 16 ms 7008 KB Output is correct
28 Incorrect 19 ms 7544 KB Output isn't correct
29 Incorrect 24 ms 9832 KB Output isn't correct
30 Incorrect 30 ms 11512 KB Output isn't correct
31 Incorrect 25 ms 9080 KB Output isn't correct
32 Incorrect 26 ms 10332 KB Output isn't correct
33 Incorrect 34 ms 12024 KB Output isn't correct
34 Incorrect 16 ms 8312 KB Output isn't correct
35 Incorrect 33 ms 12028 KB Output isn't correct
36 Incorrect 35 ms 12024 KB Output isn't correct
37 Incorrect 2 ms 760 KB Output isn't correct
38 Incorrect 973 ms 105504 KB Output isn't correct
39 Incorrect 2 ms 760 KB Output isn't correct
40 Incorrect 114 ms 29276 KB Output isn't correct
41 Incorrect 2 ms 760 KB Output isn't correct
42 Incorrect 4 ms 2424 KB Output isn't correct
43 Execution timed out 1045 ms 105568 KB Time limit exceeded
44 Incorrect 34 ms 12024 KB Output isn't correct
45 Execution timed out 1032 ms 105668 KB Time limit exceeded
46 Incorrect 980 ms 105672 KB Output isn't correct
47 Execution timed out 1014 ms 105528 KB Time limit exceeded
48 Incorrect 947 ms 105468 KB Output isn't correct
49 Incorrect 959 ms 105644 KB Output isn't correct
50 Incorrect 992 ms 105500 KB Output isn't correct
51 Execution timed out 1004 ms 105500 KB Time limit exceeded
52 Incorrect 969 ms 105632 KB Output isn't correct
53 Incorrect 968 ms 105524 KB Output isn't correct
54 Incorrect 999 ms 105532 KB Output isn't correct
55 Execution timed out 1032 ms 105576 KB Time limit exceeded
56 Incorrect 976 ms 105436 KB Output isn't correct
57 Execution timed out 1089 ms 105580 KB Time limit exceeded
58 Execution timed out 1084 ms 105488 KB Time limit exceeded
59 Execution timed out 1082 ms 105472 KB Time limit exceeded
60 Incorrect 973 ms 105712 KB Output isn't correct
61 Execution timed out 1004 ms 105676 KB Time limit exceeded
62 Execution timed out 1057 ms 105480 KB Time limit exceeded
63 Execution timed out 1065 ms 105428 KB Time limit exceeded
64 Incorrect 969 ms 105572 KB Output isn't correct
65 Incorrect 981 ms 105592 KB Output isn't correct
66 Incorrect 991 ms 105548 KB Output isn't correct
67 Incorrect 976 ms 105484 KB Output isn't correct
68 Incorrect 988 ms 105604 KB Output isn't correct
69 Execution timed out 1082 ms 105580 KB Time limit exceeded
70 Incorrect 605 ms 84600 KB Output isn't correct
71 Incorrect 984 ms 105592 KB Output isn't correct
72 Incorrect 967 ms 105536 KB Output isn't correct
73 Execution timed out 1018 ms 105576 KB Time limit exceeded
74 Incorrect 965 ms 105536 KB Output isn't correct
75 Incorrect 981 ms 105528 KB Output isn't correct
76 Incorrect 962 ms 105508 KB Output isn't correct
77 Incorrect 995 ms 105592 KB Output isn't correct
78 Incorrect 967 ms 105568 KB Output isn't correct
79 Incorrect 946 ms 105548 KB Output isn't correct
80 Incorrect 946 ms 105500 KB Output isn't correct
81 Incorrect 947 ms 105332 KB Output isn't correct
82 Incorrect 949 ms 105348 KB Output isn't correct
83 Incorrect 947 ms 105476 KB Output isn't correct
84 Incorrect 942 ms 105332 KB Output isn't correct
85 Execution timed out 1014 ms 105424 KB Time limit exceeded
86 Execution timed out 1042 ms 105312 KB Time limit exceeded
87 Incorrect 999 ms 105360 KB Output isn't correct
88 Incorrect 954 ms 105460 KB Output isn't correct
89 Incorrect 973 ms 105340 KB Output isn't correct
90 Incorrect 616 ms 84344 KB Output isn't correct
91 Incorrect 978 ms 105368 KB Output isn't correct
92 Incorrect 968 ms 105376 KB Output isn't correct
93 Execution timed out 1002 ms 105336 KB Time limit exceeded
94 Incorrect 970 ms 105252 KB Output isn't correct
95 Incorrect 957 ms 105328 KB Output isn't correct
96 Incorrect 950 ms 105252 KB Output isn't correct
97 Execution timed out 1016 ms 105336 KB Time limit exceeded
98 Incorrect 958 ms 105228 KB Output isn't correct
99 Incorrect 968 ms 105284 KB Output isn't correct
100 Incorrect 991 ms 105336 KB Output isn't correct