Submission #200089

# Submission time Handle Problem Language Result Execution time Memory
200089 2020-02-05T10:17:25 Z Saboon Sajam (COCI18_sajam) C++14
0 / 90
11 ms 1400 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 1000 + 5;

bitset <maxn> bs[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		for (int j = 0; j < n; j++){
			bs[i][j] = (s[j] == 'x');
			cnt += bs[i][j];
		}
	}
	if (cnt <= k or n * n - cnt <= k)
		return cout << "Yes" << endl, 0;
	for (int i = 0; i < n; i++){
		int tmp = 0;
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j] ^= bs[i];
			tmp += min(bs[j].count(), n - bs[j].count());
		}
		if (tmp <= k)
			return cout << "Yes" << endl, 0;
		
		tmp = 0;
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j].flip();
			int ret = bs[j].count() - (maxn - n);
			tmp += min(ret, n - ret);
		}
		if (tmp <= k)
			return cout << "Yes" << endl, 0;
		
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j].flip();
			bs[j] ^= bs[i];
		}
	}
	if (k < n)
		return cout << "No" << endl, 0;
	for (int x = 0; x < n; x++){
		bs[0][x].flip();
		int i = 0;
		int tmp = 0;
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j] ^= bs[i];
			tmp += min(bs[j].count(), n - bs[j].count());
		}
		if (tmp <= k)
			return cout << "Yes" << endl, 0;
		
		tmp = 0;
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j].flip();
			int ret = bs[j].count() - (maxn - n);
			tmp += min(ret, n - ret);
		}
		if (tmp <= k)
			return cout << "Yes" << endl, 0;
		
		for (int j = 0; j < n; j++){
			if (i == j)
				continue;
			bs[j].flip();
			bs[j] ^= bs[i];
		}
		bs[0][x].flip();
	}
	cout << "No" << endl, 0;
}

Compilation message

sajam.cpp: In function 'int main()':
sajam.cpp:93:25: warning: right operand of comma operator has no effect [-Wunused-value]
  cout << "No" << endl, 0;
                         ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -