제출 #877352

#제출 시각아이디문제언어결과실행 시간메모리
877352marcidBomb (IZhO17_bomb)C++17
24 / 100
245 ms10116 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2501;
char field[maxn][maxn];
int mn1=maxn,mn2=maxn;
int count(string s) {
	int cnt = 1; int best = s.size();
	bool ret = false; 
	for (int i = 0; i < s.size(); i++) {
		if (s[i]=='1') ret=true;
	} for (int i = 1; i < s.size(); i++) {
		if (s[i]=='1' && s[i-1]=='1') cnt++;
		else if(s[i-1]=='1' && s[i]=='0') {best=min(best,cnt);cnt=1;}
	}
	if (s.size()>1 && s[s.size()-1]=='1' && s[s.size()-2]=='0') best=1;
	return (ret ? (best) : 0);
}

signed main() {
	int n,m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> field[i][j];
		}
	} for (int i = 1; i <= n; i++) {
		string t="0";
		for (int j = 1; j <= m; j++) t+=field[i][j];
		int x = count(t+'0');
		if (x>0) mn1=min(mn1,x);
	} for (int j = 1; j <= m; j++) {
		string t="0";
		for (int i = 1; i <= n; i++) t+=field[i][j];
		int x = count(t+'0');
		if (x>0) mn2=min(mn2, x);
	} 
	cout << ((maxn==mn1 || maxn==mn2) ? 0 : mn1*mn2) <<'\n';
}

컴파일 시 표준 에러 (stderr) 메시지

bomb.cpp: In function 'long long int count(std::string)':
bomb.cpp:10:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
bomb.cpp:12:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  } for (int i = 1; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...