Submission #870814

# Submission time Handle Problem Language Result Execution time Memory
870814 2023-11-09T08:07:03 Z vjudge1 Sajam (COCI18_sajam) C++17
45 / 90
11 ms 2384 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

const int MAXN = 1E3 + 5;

char matrix[MAXN][MAXN];

#define ONLINE_JUDGE
void solve() {
    memset(matrix, 'x', sizeof(matrix));

    int n, k;
    cin >> n >> k;
    
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            cin >> matrix[i][j];
        }
    }

    auto reversex = [&](int x) -> void {
        for(int i = 1; i <= n; i++) {
            matrix[x][i] = (matrix[x][i] == 'o' ? 'x' : 'o');
        }
    };

    for(int i = 1; i <= n -1; i++) {
        if(matrix[i][1] != matrix[i +1][1]) {
            reversex(i +1);
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int cnt = 0;
        for(int j = 1; j <= n; j++) {
            cnt += (matrix[j][i] == 'o');
        }

        //cerr << i << " :: " << cnt << "\n";
        ans += min(cnt, n - cnt);
    }

    cout << (ans <= k ? "DA" : "NE");
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 3 ms 1372 KB Output is correct
4 Correct 8 ms 1448 KB Output is correct
5 Correct 4 ms 1368 KB Output is correct
6 Correct 2 ms 1372 KB Output is correct
7 Correct 3 ms 1372 KB Output is correct
8 Correct 9 ms 1448 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 10 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Incorrect 1 ms 1372 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1368 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 6 ms 2136 KB Output is correct
4 Correct 5 ms 1624 KB Output is correct
5 Correct 9 ms 2076 KB Output is correct
6 Correct 4 ms 1628 KB Output is correct
7 Correct 6 ms 1976 KB Output is correct
8 Correct 7 ms 1884 KB Output is correct
9 Correct 3 ms 1372 KB Output is correct
10 Correct 11 ms 2204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1368 KB Output is correct
2 Correct 8 ms 2140 KB Output is correct
3 Correct 7 ms 2136 KB Output is correct
4 Correct 6 ms 1880 KB Output is correct
5 Correct 6 ms 1884 KB Output is correct
6 Correct 10 ms 2140 KB Output is correct
7 Correct 3 ms 1668 KB Output is correct
8 Correct 6 ms 1884 KB Output is correct
9 Correct 7 ms 1880 KB Output is correct
10 Correct 11 ms 2328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1372 KB Output is correct
2 Correct 5 ms 1860 KB Output is correct
3 Incorrect 11 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1372 KB Output is correct
2 Correct 10 ms 2140 KB Output is correct
3 Incorrect 9 ms 2140 KB Output isn't correct
4 Halted 0 ms 0 KB -