답안 #832239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832239 2023-08-21T07:27:23 Z vjudge1 Bomb (IZhO17_bomb) C++14
26 / 100
1000 ms 56744 KB
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define ll long long
#define rep(i,n,N) for(int i = n; i<=N; ++i)
#define rap(i,n,N) for(int i = n; i>=N; --i)
#define For(i,n,N) for(int i = n; i< N; ++i)
#define endl '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define mems(x,y) memset(x,y,sizeof x)
#define ari(x) array<int,x>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
const int MAX = 2500 + 5;
mt19937 rng(time(NULL));

int n,m,mnr,mnc,cnt,y[MAX][MAX],z[MAX][MAX];
char c;
bool x[MAX][MAX];
vector<ari(3)> v;

inline bool cek(int r,int c,int dr,int dc){
	return y[r][c] - y[r-dr][c] - y[r][c-dc] + y[r-dr][c-dc] == dr*dc;
}

inline void solve(int dr,int dc){
	mems(z, 0);
	rep(i,dr,n)rep(j,dc,m)if(x[i][j] && cek(i,j,dr,dc)){
		z[i][j]++;
		z[i-dr][j]--;
		z[i][j-dc]--;
		z[i-dr][j-dc]++;
	}
	rap(i,n,1)rap(j,m,1){
		z[i][j]+= z[i+1][j]+z[i][j+1]-z[i+1][j+1];
		if((!!z[i][j])!=x[i][j])return;
	}
	cout<<dr*dc<<endl;
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	mnr = n, mnc = m;
	rep(i,1,n){
		rep(j,1,m){
			cin>>c;
			x[i][j] = c=='1';
			y[i][j] = y[i-1][j]+y[i][j-1]-y[i-1][j-1]+x[i][j];
			if(x[i][j])++cnt;
			else if(cnt)mnc = min(mnc, cnt), cnt = 0;
		}
		if(cnt)mnc = min(mnc, cnt), cnt = 0;
	}
	rep(j,1,m){
		rep(i,1,n){
			if(x[i][j])++cnt;
			else if(cnt)mnr = min(mnr, cnt), cnt = 0;
		}
		if(cnt)mnr = min(mnr, cnt), cnt = 0;
	}
	solve(mnr, mnc);
	int ar = max(1, mnr-100);
	int ac = max(1, mnc-100);
	rep(i,ar,mnr)rep(j,ac,mnc)v.pb({i*j, i, j});
	v.pop_back();
	sort(all(v));
	reverse(all(v));
	for(auto &i:v)solve(i[1], i[2]), cout<<i[1]<<" "<<i[2]<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 24784 KB Output is correct
2 Correct 9 ms 24916 KB Output is correct
3 Correct 17 ms 41012 KB Output is correct
4 Correct 16 ms 40964 KB Output is correct
5 Correct 8 ms 24916 KB Output is correct
6 Correct 11 ms 24848 KB Output is correct
7 Correct 9 ms 24908 KB Output is correct
8 Incorrect 26 ms 25032 KB Output isn't correct
9 Incorrect 29 ms 24936 KB Output isn't correct
10 Correct 12 ms 24916 KB Output is correct
11 Incorrect 46 ms 24960 KB Output isn't correct
12 Correct 12 ms 24916 KB Output is correct
13 Correct 9 ms 24972 KB Output is correct
14 Correct 10 ms 24908 KB Output is correct
15 Incorrect 33 ms 24916 KB Output isn't correct
16 Correct 10 ms 24928 KB Output is correct
17 Correct 10 ms 25300 KB Output is correct
18 Incorrect 22 ms 25272 KB Output isn't correct
19 Incorrect 466 ms 25536 KB Output isn't correct
20 Incorrect 476 ms 25528 KB Output isn't correct
21 Incorrect 24 ms 25196 KB Output isn't correct
22 Incorrect 38 ms 25300 KB Output isn't correct
23 Incorrect 487 ms 25608 KB Output isn't correct
24 Incorrect 490 ms 25452 KB Output isn't correct
25 Execution timed out 1080 ms 25628 KB Time limit exceeded
26 Correct 11 ms 25556 KB Output is correct
27 Correct 11 ms 27092 KB Output is correct
28 Incorrect 55 ms 27220 KB Output isn't correct
29 Execution timed out 1089 ms 28180 KB Time limit exceeded
30 Execution timed out 1078 ms 28892 KB Time limit exceeded
31 Execution timed out 1048 ms 27968 KB Time limit exceeded
32 Execution timed out 1077 ms 28448 KB Time limit exceeded
33 Execution timed out 1080 ms 29048 KB Time limit exceeded
34 Incorrect 64 ms 27604 KB Output isn't correct
35 Execution timed out 1088 ms 28764 KB Time limit exceeded
36 Correct 14 ms 28756 KB Output is correct
37 Incorrect 42 ms 25016 KB Output isn't correct
38 Correct 100 ms 56296 KB Output is correct
39 Incorrect 52 ms 25008 KB Output isn't correct
40 Execution timed out 1073 ms 34192 KB Time limit exceeded
41 Incorrect 43 ms 25016 KB Output isn't correct
42 Execution timed out 1089 ms 25660 KB Time limit exceeded
43 Correct 107 ms 56212 KB Output is correct
44 Execution timed out 1090 ms 29048 KB Time limit exceeded
45 Execution timed out 1031 ms 56524 KB Time limit exceeded
46 Correct 118 ms 56248 KB Output is correct
47 Execution timed out 1043 ms 56492 KB Time limit exceeded
48 Execution timed out 1046 ms 56372 KB Time limit exceeded
49 Correct 136 ms 56200 KB Output is correct
50 Execution timed out 1067 ms 56432 KB Time limit exceeded
51 Execution timed out 1032 ms 56328 KB Time limit exceeded
52 Execution timed out 1051 ms 56396 KB Time limit exceeded
53 Execution timed out 1016 ms 56428 KB Time limit exceeded
54 Execution timed out 1029 ms 56440 KB Time limit exceeded
55 Execution timed out 1076 ms 56380 KB Time limit exceeded
56 Correct 106 ms 56300 KB Output is correct
57 Execution timed out 1025 ms 56428 KB Time limit exceeded
58 Execution timed out 1048 ms 56332 KB Time limit exceeded
59 Execution timed out 1037 ms 56392 KB Time limit exceeded
60 Correct 116 ms 56296 KB Output is correct
61 Correct 109 ms 56184 KB Output is correct
62 Correct 110 ms 56180 KB Output is correct
63 Correct 104 ms 56172 KB Output is correct
64 Correct 112 ms 56176 KB Output is correct
65 Execution timed out 1034 ms 56320 KB Time limit exceeded
66 Incorrect 169 ms 56284 KB Output isn't correct
67 Execution timed out 1040 ms 56368 KB Time limit exceeded
68 Incorrect 856 ms 56380 KB Output isn't correct
69 Execution timed out 1031 ms 56356 KB Time limit exceeded
70 Execution timed out 1040 ms 50000 KB Time limit exceeded
71 Execution timed out 1010 ms 56488 KB Time limit exceeded
72 Execution timed out 1048 ms 56592 KB Time limit exceeded
73 Execution timed out 1043 ms 56628 KB Time limit exceeded
74 Execution timed out 1094 ms 56552 KB Time limit exceeded
75 Execution timed out 1043 ms 56576 KB Time limit exceeded
76 Execution timed out 1052 ms 56556 KB Time limit exceeded
77 Execution timed out 1031 ms 56556 KB Time limit exceeded
78 Execution timed out 1014 ms 56512 KB Time limit exceeded
79 Execution timed out 1035 ms 56304 KB Time limit exceeded
80 Execution timed out 1026 ms 56320 KB Time limit exceeded
81 Execution timed out 1037 ms 56536 KB Time limit exceeded
82 Execution timed out 1014 ms 56572 KB Time limit exceeded
83 Execution timed out 1030 ms 56528 KB Time limit exceeded
84 Execution timed out 1086 ms 56312 KB Time limit exceeded
85 Execution timed out 1024 ms 56504 KB Time limit exceeded
86 Execution timed out 1045 ms 56268 KB Time limit exceeded
87 Execution timed out 1049 ms 56540 KB Time limit exceeded
88 Execution timed out 1020 ms 56564 KB Time limit exceeded
89 Execution timed out 1043 ms 56572 KB Time limit exceeded
90 Execution timed out 1079 ms 50048 KB Time limit exceeded
91 Execution timed out 1074 ms 56496 KB Time limit exceeded
92 Execution timed out 1057 ms 56500 KB Time limit exceeded
93 Execution timed out 1070 ms 56340 KB Time limit exceeded
94 Execution timed out 1068 ms 56600 KB Time limit exceeded
95 Execution timed out 1059 ms 56636 KB Time limit exceeded
96 Execution timed out 1045 ms 56536 KB Time limit exceeded
97 Execution timed out 1048 ms 56340 KB Time limit exceeded
98 Execution timed out 1027 ms 56556 KB Time limit exceeded
99 Execution timed out 1066 ms 56532 KB Time limit exceeded
100 Execution timed out 1041 ms 56744 KB Time limit exceeded