답안 #37649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37649 2017-12-26T15:51:40 Z Kerim Bomb (IZhO17_bomb) C++14
31 / 100
1000 ms 8172 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=2509;
char arr[N][N];
bool vis[101][101];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf(" %c",&arr[i][j]);
	if(n<=100 and m<=100){
		int ans=0;		
		for(int x=1;x<=n;x++)
			for(int y=1;y<=m;y++){
				memset(vis,0,sizeof vis);
				for(int i=1;i+x-1<=n;i++)
					for(int j=1;j+y-1<=m;j++){
						bool ok=1;
						for(int i1=i;i1<=i+x-1;i1++)
							for(int j1=j;j1<=j+y-1;j1++)
								if(arr[i1][j1]=='0')
									ok=0;
						if(ok){
							for(int i1=i;i1<=i+x-1;i1++)
								for(int j1=j;j1<=j+y-1;j1++)
									vis[i1][j1]=1;
						}
					}
				bool ok=1;	
				for(int i=1;i<=n;i++)
					for(int j=1;j<=m;j++)
						if(!vis[i][j] and arr[i][j]=='1')
							ok=0;
				if(ok)			
					umax(ans,x*y);
		}
		printf("%d\n",ans);
		return 0;
	}		
	int xx=INF,yy=INF;		
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=1;j<=m;j++){
			if(arr[i][j]=='0'){
				if(cnt)
					umin(yy,cnt);
				cnt=0;	
			}
			else
				cnt++;
		}
		if(cnt)
			umin(yy,cnt);
	}	
	for(int j=1;j<=m;j++){
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(arr[i][j]=='0'){
				if(cnt)
					umin(xx,cnt);
				cnt=0;	
			}
			else
				cnt++;
		}
		if(cnt)
			umin(xx,cnt);
	}
	if(xx==INF)
		xx=n;
	printf("%d\n",xx*yy);
	return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:26:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
bomb.cpp:29:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&arr[i][j]);
                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8172 KB Output is correct
2 Correct 0 ms 8172 KB Output is correct
3 Correct 3 ms 8172 KB Output is correct
4 Correct 0 ms 8172 KB Output is correct
5 Correct 0 ms 8172 KB Output is correct
6 Correct 0 ms 8172 KB Output is correct
7 Correct 0 ms 8172 KB Output is correct
8 Correct 3 ms 8172 KB Output is correct
9 Correct 3 ms 8172 KB Output is correct
10 Correct 0 ms 8172 KB Output is correct
11 Correct 3 ms 8172 KB Output is correct
12 Correct 0 ms 8172 KB Output is correct
13 Correct 0 ms 8172 KB Output is correct
14 Correct 0 ms 8172 KB Output is correct
15 Correct 0 ms 8172 KB Output is correct
16 Correct 3 ms 8172 KB Output is correct
17 Execution timed out 1000 ms 8172 KB Execution timed out
18 Execution timed out 1000 ms 8172 KB Execution timed out
19 Execution timed out 1000 ms 8172 KB Execution timed out
20 Execution timed out 1000 ms 8172 KB Execution timed out
21 Execution timed out 1000 ms 8172 KB Execution timed out
22 Execution timed out 1000 ms 8172 KB Execution timed out
23 Execution timed out 1000 ms 8172 KB Execution timed out
24 Execution timed out 1000 ms 8172 KB Execution timed out
25 Execution timed out 1000 ms 8172 KB Execution timed out
26 Execution timed out 1000 ms 8172 KB Execution timed out
27 Correct 0 ms 8172 KB Output is correct
28 Incorrect 6 ms 8172 KB Output isn't correct
29 Incorrect 9 ms 8172 KB Output isn't correct
30 Incorrect 13 ms 8172 KB Output isn't correct
31 Incorrect 9 ms 8172 KB Output isn't correct
32 Incorrect 9 ms 8172 KB Output isn't correct
33 Incorrect 9 ms 8172 KB Output isn't correct
34 Incorrect 6 ms 8172 KB Output isn't correct
35 Incorrect 16 ms 8172 KB Output isn't correct
36 Correct 13 ms 8172 KB Output is correct
37 Correct 3 ms 8172 KB Output is correct
38 Correct 419 ms 8172 KB Output is correct
39 Correct 3 ms 8172 KB Output is correct
40 Incorrect 59 ms 8172 KB Output isn't correct
41 Correct 3 ms 8172 KB Output is correct
42 Execution timed out 1000 ms 8172 KB Execution timed out
43 Correct 406 ms 8172 KB Output is correct
44 Incorrect 13 ms 8172 KB Output isn't correct
45 Incorrect 443 ms 8172 KB Output isn't correct
46 Correct 453 ms 8172 KB Output is correct
47 Incorrect 416 ms 8172 KB Output isn't correct
48 Incorrect 429 ms 8172 KB Output isn't correct
49 Correct 416 ms 8172 KB Output is correct
50 Incorrect 383 ms 8172 KB Output isn't correct
51 Incorrect 416 ms 8172 KB Output isn't correct
52 Incorrect 429 ms 8172 KB Output isn't correct
53 Incorrect 396 ms 8172 KB Output isn't correct
54 Incorrect 406 ms 8172 KB Output isn't correct
55 Incorrect 373 ms 8172 KB Output isn't correct
56 Correct 489 ms 8172 KB Output is correct
57 Incorrect 456 ms 8172 KB Output isn't correct
58 Incorrect 403 ms 8172 KB Output isn't correct
59 Incorrect 396 ms 8172 KB Output isn't correct
60 Correct 466 ms 8172 KB Output is correct
61 Correct 503 ms 8172 KB Output is correct
62 Correct 399 ms 8172 KB Output is correct
63 Correct 409 ms 8172 KB Output is correct
64 Correct 366 ms 8172 KB Output is correct
65 Incorrect 423 ms 8172 KB Output isn't correct
66 Incorrect 433 ms 8172 KB Output isn't correct
67 Incorrect 359 ms 8172 KB Output isn't correct
68 Incorrect 376 ms 8172 KB Output isn't correct
69 Incorrect 369 ms 8172 KB Output isn't correct
70 Incorrect 239 ms 8172 KB Output isn't correct
71 Incorrect 389 ms 8172 KB Output isn't correct
72 Incorrect 439 ms 8172 KB Output isn't correct
73 Incorrect 446 ms 8172 KB Output isn't correct
74 Incorrect 526 ms 8172 KB Output isn't correct
75 Incorrect 449 ms 8172 KB Output isn't correct
76 Incorrect 429 ms 8172 KB Output isn't correct
77 Incorrect 439 ms 8172 KB Output isn't correct
78 Incorrect 376 ms 8172 KB Output isn't correct
79 Incorrect 403 ms 8172 KB Output isn't correct
80 Incorrect 419 ms 8172 KB Output isn't correct
81 Incorrect 469 ms 8172 KB Output isn't correct
82 Incorrect 423 ms 8172 KB Output isn't correct
83 Incorrect 429 ms 8172 KB Output isn't correct
84 Incorrect 443 ms 8172 KB Output isn't correct
85 Incorrect 409 ms 8172 KB Output isn't correct
86 Incorrect 396 ms 8172 KB Output isn't correct
87 Incorrect 389 ms 8172 KB Output isn't correct
88 Incorrect 409 ms 8172 KB Output isn't correct
89 Incorrect 463 ms 8172 KB Output isn't correct
90 Incorrect 279 ms 8172 KB Output isn't correct
91 Incorrect 416 ms 8172 KB Output isn't correct
92 Incorrect 389 ms 8172 KB Output isn't correct
93 Incorrect 439 ms 8172 KB Output isn't correct
94 Incorrect 423 ms 8172 KB Output isn't correct
95 Incorrect 396 ms 8172 KB Output isn't correct
96 Incorrect 413 ms 8172 KB Output isn't correct
97 Incorrect 546 ms 8172 KB Output isn't correct
98 Incorrect 463 ms 8172 KB Output isn't correct
99 Incorrect 426 ms 8172 KB Output isn't correct
100 Incorrect 413 ms 8172 KB Output isn't correct