Submission #311205

#TimeUsernameProblemLanguageResultExecution timeMemory
311205phathnvSajam (COCI18_sajam)C++11
90 / 90
138 ms1528 KiB
#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)

sajam.cpp: In function 'void readInput()':
sajam.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
sajam.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%s", s + 1);
      |         ~~~~~^~~~~~~~~~~~~
#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...