Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 12:09:39
2018-05-26 11:56:45
Task:Grid
Sender:Oispa nutellaa
Submission time:2018-05-26 12:09:39
Status:READY
Result:ACCEPTED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:10:7: warning: unused variable 'kaikki' [-Wunused-variable]
  bool kaikki = false;
       ^~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

int n, rdk[1010][1010], vaaka[1010], pysty[1010], ans, lsk;
char cha;

int main() {
	cin >> n;
	bool kaikki = false;
	for(int i=0; i<n; i++) {
	int cnt = 0;
		for(int j=0; j<n; j++) {
			cin >> cha;
			rdk[j][i] = cha-'0';
			if(rdk[j][i]) {
			 cnt++;
			 lsk++;
			 }
		}
		if(cnt==n) {
		ans++;
		vaaka[i] = 1;
		}
		else if(cnt) {
			for(int j=0; j<n; j++) {
				if(rdk[j][i])
					pysty[j] = 1;
			}
		}

	}
	if(lsk==n*n) {
	cout << n;
		exit(0);
	}
	for(int i=0; i<n; i++) {
		int cnt = 0;
		bool pitol = false;
		for(int j=0; j<n; j++) {
			if(rdk[i][j])
				cnt++;
			if(rdk[i][j]==1&&vaaka[j]==0) {
				pitol=true;
				}
		}
		if(cnt==n) {
			ans++;
		} else if(pysty[i]||pitol) {
			cout << -1;
			exit(0);
		}
	}
	cout << ans;
}