제출 #200091

#제출 시각아이디문제언어결과실행 시간메모리
200091SaboonSajam (COCI18_sajam)C++14
90 / 90
399 ms1528 KiB
#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 << "DA" << 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 << "DA" << 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 << "DA" << 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 << "NE" << 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 << "DA" << 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 << "DA" << 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 << "NE" << endl, 0;
}

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

sajam.cpp: In function 'int main()':
sajam.cpp:93:25: warning: right operand of comma operator has no effect [-Wunused-value]
  cout << "NE" << endl, 0;
                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...