# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311205 | phathnv | Sajam (COCI18_sajam) | C++11 | 138 ms | 1528 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "SAJAM"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 1001;
int n, k;
char s[N];
bitset <N> a[N];
void readInput(){
scanf("%d %d", &n, &k);
for(int i = 1; i <= n; i++){
scanf("%s", s + 1);
for(int j = 1; j <= n; j++)
a[i][j] = (s[j] == 'o');
}
}
int calc(int x1, int x2){
int res = (a[x1] ^ a[x2]).count();
if (res > n / 2)
res = n - res;
return res;
}
void solve(){
for(int i = 1; i <= n; i++){
int cnt = 0;
for(int j = 1; j <= n; j++)
cnt += calc(i, j);
if (cnt <= k){
printf("DA");
return;
}
}
if (k < n){
printf("NE");
return;
}
for(int i = 1; i <= n; i++){
a[1][i].flip();
int cnt = 1;
for(int j = 1; j <= n; j++)
cnt += calc(1, j);
if (cnt <= k){
printf("DA");
return;
}
a[1][i].flip();
}
printf("NE");
}
int main(){
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
readInput();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |