Submission #508714

# Submission time Handle Problem Language Result Execution time Memory
508714 2022-01-13T15:18:03 Z David_M Sajam (COCI18_sajam) C++17
90 / 90
252 ms 1328 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e9, P=998244353;

int q=1, n, m, x, y, c, l, r, k, a[N], f[N], ansl, ansr, ans, o, u, Ans;
string s;
bitset<1000> b[1000];
int xorr(bitset<1000> x, bitset<1000> y){return min((int)(x^y).count(), (int)(n-(x^y).count()));}
int solve(int i){
    int ans=0;
    for (int j=0; j<n; j++)ans+=xorr(b[i],b[j]);
    return ans;
}
main(){ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n>>k;
    Ans=INF;
    for (int i=0; i<n; i++){
        cin>>s;
        int j=0;
        for(auto c:s)b[i][j++]=(c=='x');
    }
    for (int i=0; i<n; i++)Ans=min(solve(i), Ans);
    if(k==n){
        for (int i=0; i<n; i++){
            b[0][i].flip();
            Ans=min(solve(0)+1, Ans);
            b[0][i].flip();
        }
    }

	puts((Ans<=k) ? "DA":"NE");

}
/*
3 2
xxo
xox
oxx
*/

Compilation message

sajam.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 22 ms 384 KB Output is correct
3 Correct 36 ms 372 KB Output is correct
4 Correct 107 ms 420 KB Output is correct
5 Correct 41 ms 332 KB Output is correct
6 Correct 20 ms 332 KB Output is correct
7 Correct 34 ms 368 KB Output is correct
8 Correct 109 ms 420 KB Output is correct
9 Correct 7 ms 356 KB Output is correct
10 Correct 110 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 4 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 332 KB Output is correct
2 Correct 96 ms 412 KB Output is correct
3 Correct 65 ms 332 KB Output is correct
4 Correct 52 ms 384 KB Output is correct
5 Correct 107 ms 332 KB Output is correct
6 Correct 37 ms 384 KB Output is correct
7 Correct 68 ms 332 KB Output is correct
8 Correct 77 ms 332 KB Output is correct
9 Correct 22 ms 332 KB Output is correct
10 Correct 127 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 420 KB Output is correct
2 Correct 92 ms 416 KB Output is correct
3 Correct 53 ms 332 KB Output is correct
4 Correct 97 ms 400 KB Output is correct
5 Correct 73 ms 404 KB Output is correct
6 Correct 120 ms 432 KB Output is correct
7 Correct 28 ms 332 KB Output is correct
8 Correct 70 ms 340 KB Output is correct
9 Correct 73 ms 332 KB Output is correct
10 Correct 125 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 388 KB Output is correct
2 Correct 110 ms 388 KB Output is correct
3 Correct 251 ms 428 KB Output is correct
4 Correct 76 ms 380 KB Output is correct
5 Correct 120 ms 392 KB Output is correct
6 Correct 233 ms 428 KB Output is correct
7 Correct 69 ms 588 KB Output is correct
8 Correct 79 ms 588 KB Output is correct
9 Correct 84 ms 708 KB Output is correct
10 Correct 80 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 252 ms 436 KB Output is correct
2 Correct 242 ms 424 KB Output is correct
3 Correct 219 ms 420 KB Output is correct
4 Correct 133 ms 396 KB Output is correct
5 Correct 131 ms 408 KB Output is correct
6 Correct 141 ms 396 KB Output is correct
7 Correct 98 ms 664 KB Output is correct
8 Correct 214 ms 1224 KB Output is correct
9 Correct 114 ms 792 KB Output is correct
10 Correct 231 ms 1328 KB Output is correct