Submission #92093

#TimeUsernameProblemLanguageResultExecution timeMemory
92093KastandaSajam (COCI18_sajam)C++11
90 / 90
492 ms632 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, k;
char S[N];
bitset < N > A[N], B[N];
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", &S);
        for (int j = 0; j < n; j++)
            A[i][j] = (S[j] == 'o'), B[i][j] = !A[i][j];
        memset(S, 0, sizeof(S));
    }
    for (int i = 0; i < n; i++)
    {
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            int a = (A[i] ^ A[j]).count();
            int b = (B[i] ^ A[j]).count();
            int c = (A[i] ^ B[j]).count();
            int d = (B[i] ^ B[j]).count();
            cnt += min({a, b, c, d});
        }
        if (cnt <= k)
            return !printf("DA\n");
    }
    if (k == n)
    {
        for (int i = 0; i < n; i++)
        {
            A[0][i] = !A[0][i];
            B[0][i] = !B[0][i];
            int cnt = 0;
            for (int j = 0; j < n; j++)
            {
                int a = (A[0] ^ A[j]).count();
                int b = (B[0] ^ A[j]).count();
                int c = (A[0] ^ B[j]).count();
                int d = (B[0] ^ B[j]).count();
                cnt += min({a, b, c, d});
            }
            if (cnt <= k)
                return !printf("DA\n");
            A[0][i] = !A[0][i];
            B[0][i] = !B[0][i];
        }
    }
    return !printf("NE\n");
}

Compilation message (stderr)

sajam.cpp: In function 'int main()':
sajam.cpp:12:23: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[1003]' [-Wformat=]
         scanf("%s", &S);
                     ~~^
sajam.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
sajam.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", &S);
         ~~~~~^~~~~~~~~~
#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...