Submission #1131443


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef long long lint;
const int mod = 1e9 + 7;

int n;
char a[505][505];

int main(){
	cin >> n;
	bool ok = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(count(a[i], a[i] + n, '#') > 0) ok = 1;
	}
	if(!ok){
		puts("-1");
		return 0;
	}
	int ans = 1e9;
	for(int i=0; i<n; i++){
		bool fnd = 0, fnd2 = 0;
		int tmp = 0;
		for(int j=0; j<n; j++){
			if(a[j][i] == '#'){
				if(count(a[j], a[j] + n, '.') == 0){
					fnd2 = 1;
				}
				fnd = 1;
			}
		}
		int full = 0;
		for(int j=0; j<n; j++){
			if(a[i][j] == '.') tmp++;
			bool bad = 0;
			for(int k=0; k<n; k++){
				if(a[k][j] == '.') bad = 1;
			}
			if(!bad) full++;
		}
		if(fnd2){
			ans = min(ans, n - full);
		}
		else{
			ans = min(ans, tmp + n - full);
		}
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task B - Row to Column
User koosaga
Language C++14 (GCC 5.4.1)
Score 0
Code Size 873 Byte
Status WA
Exec Time 204 ms
Memory 512 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 0 / 300 0 / 1000
Status
AC × 5
AC × 16
WA × 4
AC × 34
WA × 9
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
Subtask 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
0_04.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt WA 1 ms 256 KB
1_04.txt WA 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt WA 1 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt AC 1 ms 256 KB
1_09.txt AC 1 ms 256 KB
1_10.txt WA 1 ms 256 KB
1_11.txt AC 1 ms 256 KB
1_12.txt AC 1 ms 256 KB
1_13.txt AC 1 ms 256 KB
1_14.txt AC 1 ms 256 KB
2_00.txt AC 9 ms 512 KB
2_01.txt AC 204 ms 512 KB
2_02.txt AC 113 ms 512 KB
2_03.txt WA 113 ms 512 KB
2_04.txt WA 113 ms 512 KB
2_05.txt AC 113 ms 512 KB
2_06.txt WA 113 ms 512 KB
2_07.txt AC 93 ms 512 KB
2_08.txt AC 150 ms 512 KB
2_09.txt AC 139 ms 512 KB
2_10.txt AC 151 ms 512 KB
2_11.txt AC 161 ms 512 KB
2_12.txt AC 153 ms 512 KB
2_13.txt WA 118 ms 512 KB
2_14.txt WA 120 ms 512 KB
2_15.txt AC 83 ms 512 KB
2_16.txt AC 88 ms 512 KB
2_17.txt AC 76 ms 512 KB
2_18.txt AC 59 ms 384 KB
2_19.txt AC 185 ms 512 KB
2_20.txt AC 109 ms 384 KB
2_21.txt AC 96 ms 384 KB
2_22.txt AC 198 ms 512 KB