Submission #884180

# Submission time Handle Problem Language Result Execution time Memory
884180 2023-12-06T16:50:38 Z vjudge1 Sajam (COCI18_sajam) C++17
45 / 90
14 ms 8284 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 998244353
#define lim 200005
using namespace std;





void solve(){
    int n, k; cin >> n >> k;
    int arr[n+1][n+1];
    for(int i=1; i<=n; i++){
        string s; cin >> s;
        for(int j=1; j<=n; j++){
            if(s[j-1]=='o') arr[i][j]=1;
            else arr[i][j]=0;
        }
    }
    int color[2][n+1];
    color[0][1]=0;
    for(int i=1; i<=n; i++){
        color[1][i] = arr[1][i];
        //cerr << "column" spc i spc color[1][i] << endl;
    }
    for(int i=1; i<=n; i++){
        color[0][i] = (arr[i][1]==1)?(1-color[1][1]):(color[1][1]);
        //cerr << "row" spc i spc color[0][i] << endl;
    }
    int ans=0, ans2=0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if((color[0][i]!=color[1][j])!=arr[i][j])ans++;
            else ans2++;
        }
    }
    cerr << ans spc ans2 << endl;
    if(min(ans,ans2)<=k) cout << "DA" << endl;
    else cout << "NE" << endl;
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif

    /*freopen("fcolor.in","r",stdin);
    freopen("fcolor.out","w",stdout);*/

    int t=1;
    //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 6 ms 6748 KB Output is correct
5 Correct 2 ms 2392 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 4 ms 2396 KB Output is correct
8 Correct 12 ms 7260 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 12 ms 7644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4700 KB Output is correct
2 Correct 5 ms 5720 KB Output is correct
3 Correct 3 ms 3932 KB Output is correct
4 Correct 3 ms 3420 KB Output is correct
5 Correct 7 ms 6748 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 5 ms 4700 KB Output is correct
8 Correct 5 ms 4956 KB Output is correct
9 Correct 3 ms 1772 KB Output is correct
10 Correct 14 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6236 KB Output is correct
2 Correct 5 ms 6236 KB Output is correct
3 Correct 3 ms 3928 KB Output is correct
4 Correct 4 ms 4700 KB Output is correct
5 Correct 4 ms 4956 KB Output is correct
6 Correct 7 ms 7772 KB Output is correct
7 Correct 2 ms 2140 KB Output is correct
8 Correct 4 ms 4540 KB Output is correct
9 Correct 9 ms 4952 KB Output is correct
10 Correct 14 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3672 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
3 Incorrect 7 ms 8076 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8284 KB Output is correct
2 Correct 7 ms 7772 KB Output is correct
3 Incorrect 6 ms 7260 KB Output isn't correct
4 Halted 0 ms 0 KB -