Submission #200583

# Submission time Handle Problem Language Result Execution time Memory
200583 2020-02-07T13:04:39 Z Asrapogorgon Sajam (COCI18_sajam) C++14
45 / 90
227 ms 576 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long 
const int maxn=1e3+5;
/*Almost copy pasted part :)*/
bitset <maxn> bit[maxn];
#define YES "DA"
#define NO "NE"
int32_t main(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    for(int i=0;i<n;i++){
        int u=0;
        for(int j=0;j<n;j++){
            char a;
            cin>>a;
            bit[i][j]=(a=='x');
            u+=bit[i][j];
        }
        cnt+=min(u,n-u);
    }
    if(cnt<=k){
        cout<<YES<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            int z=(bit[i]^bit[j]).count();
            cnt+=min(z,n-z);
        }
        if(cnt<=k){
            cout<<YES<<endl;
            return 0;
        }
    }
    bitset<maxn>b=bit[0];
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            int cn=(bit[j]^b).count();
            cn=min(cn,n-cn);
            cnt+=cn;
        }  
        if(cnt<=k){
            cout<<YES<<endl;
            return 0;
        }
        b[i]=(1-b[i]);
    }   
    cout<<NO<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 23 ms 376 KB Output is correct
3 Correct 28 ms 380 KB Output is correct
4 Correct 78 ms 376 KB Output is correct
5 Correct 29 ms 504 KB Output is correct
6 Correct 14 ms 380 KB Output is correct
7 Correct 59 ms 376 KB Output is correct
8 Correct 190 ms 504 KB Output is correct
9 Correct 19 ms 376 KB Output is correct
10 Correct 200 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 7 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 376 KB Output is correct
2 Correct 67 ms 504 KB Output is correct
3 Correct 45 ms 372 KB Output is correct
4 Correct 43 ms 376 KB Output is correct
5 Correct 76 ms 380 KB Output is correct
6 Correct 68 ms 376 KB Output is correct
7 Correct 126 ms 576 KB Output is correct
8 Correct 141 ms 376 KB Output is correct
9 Correct 40 ms 376 KB Output is correct
10 Correct 222 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 376 KB Output is correct
2 Correct 70 ms 504 KB Output is correct
3 Correct 41 ms 376 KB Output is correct
4 Correct 52 ms 376 KB Output is correct
5 Correct 55 ms 376 KB Output is correct
6 Correct 207 ms 504 KB Output is correct
7 Correct 55 ms 504 KB Output is correct
8 Correct 116 ms 380 KB Output is correct
9 Correct 134 ms 376 KB Output is correct
10 Correct 227 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 380 KB Output is correct
2 Correct 43 ms 376 KB Output is correct
3 Incorrect 217 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 93 ms 376 KB Output is correct
2 Correct 88 ms 376 KB Output is correct
3 Incorrect 194 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -