답안 #200091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200091 2020-02-05T10:18:22 Z Saboon Sajam (COCI18_sajam) C++14
90 / 90
399 ms 1528 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 << "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;
}

Compilation message

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;
                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 632 KB Output is correct
3 Correct 6 ms 632 KB Output is correct
4 Correct 9 ms 1272 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 60 ms 632 KB Output is correct
8 Correct 199 ms 1400 KB Output is correct
9 Correct 16 ms 376 KB Output is correct
10 Correct 206 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 380 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 504 KB Output is correct
2 Correct 9 ms 1148 KB Output is correct
3 Correct 7 ms 888 KB Output is correct
4 Correct 7 ms 764 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 69 ms 632 KB Output is correct
7 Correct 136 ms 1144 KB Output is correct
8 Correct 142 ms 1144 KB Output is correct
9 Correct 42 ms 556 KB Output is correct
10 Correct 231 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 9 ms 1164 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 8 ms 888 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 213 ms 1432 KB Output is correct
7 Correct 54 ms 632 KB Output is correct
8 Correct 120 ms 888 KB Output is correct
9 Correct 133 ms 1020 KB Output is correct
10 Correct 237 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 888 KB Output is correct
3 Correct 325 ms 1404 KB Output is correct
4 Correct 118 ms 632 KB Output is correct
5 Correct 128 ms 932 KB Output is correct
6 Correct 399 ms 1400 KB Output is correct
7 Correct 131 ms 632 KB Output is correct
8 Correct 140 ms 760 KB Output is correct
9 Correct 150 ms 760 KB Output is correct
10 Correct 152 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 504 KB Output is correct
2 Correct 10 ms 1400 KB Output is correct
3 Correct 295 ms 1352 KB Output is correct
4 Correct 238 ms 888 KB Output is correct
5 Correct 128 ms 1016 KB Output is correct
6 Correct 253 ms 1016 KB Output is correct
7 Correct 134 ms 760 KB Output is correct
8 Correct 332 ms 1144 KB Output is correct
9 Correct 195 ms 888 KB Output is correct
10 Correct 398 ms 1400 KB Output is correct