답안 #870819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870819 2023-11-09T08:15:52 Z vjudge1 Sajam (COCI18_sajam) C++17
45 / 90
594 ms 1444 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64

const int MAXN = 1E3 + 5;

char matrix[MAXN][MAXN];

#define ONLINE_JUDGE
void solve() {
    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');
        }
    };

    int anss = int(1E18);
    for(int t = 1; t <= n && anss > k; t++) {
        for(int i = 1; i <= n -1; i++) {
            if(matrix[i][t] != matrix[i +1][t]) {
                reversex(i +1);
            }
        }

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

            ans += min(cnto, n - cnto);
        }

        anss = min(anss, ans);
    }

    cout << (anss <= 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 3 ms 736 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 64 ms 816 KB Output is correct
8 Correct 389 ms 1348 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 398 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1104 KB Output is correct
2 Correct 7 ms 1112 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 8 ms 1116 KB Output is correct
6 Correct 99 ms 860 KB Output is correct
7 Correct 296 ms 1168 KB Output is correct
8 Correct 321 ms 1116 KB Output is correct
9 Correct 32 ms 600 KB Output is correct
10 Correct 471 ms 1416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1112 KB Output is correct
2 Correct 9 ms 1116 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 7 ms 1112 KB Output is correct
6 Correct 594 ms 1372 KB Output is correct
7 Correct 63 ms 860 KB Output is correct
8 Correct 278 ms 1152 KB Output is correct
9 Correct 210 ms 1112 KB Output is correct
10 Correct 468 ms 1420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 856 KB Output is correct
2 Correct 5 ms 860 KB Output is correct
3 Incorrect 427 ms 1372 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1444 KB Output is correct
2 Correct 10 ms 1372 KB Output is correct
3 Incorrect 339 ms 1372 KB Output isn't correct
4 Halted 0 ms 0 KB -