이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |