Submission #522848

# Submission time Handle Problem Language Result Execution time Memory
522848 2022-02-06T04:13:23 Z KoD Sajam (COCI18_sajam) C++17
45 / 90
125 ms 1344 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, K;
    std::cin >> N >> K;
    vector<std::bitset<1000>> B(N);
    for (auto& x : B) {
        for (int i = 0; i < N; ++i) {
            char c;
            std::cin >> c;
            if (c == 'o') {
                x.set(i);
            }
        }
    }
    const auto cost = [&](const int i, const int j) {
        const int dif = (B[i] ^ B[j]).count();
        return std::min(dif, N - dif);
    };
    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = 0; j < N; ++j) {
            sum += cost(i, j);
        }
        if (sum <= K) {
            std::cout << "DA\n";
            return 0;
        }
    }
    for (int i = 0; i < N; ++i) {
        B[0].flip(i);
        int sum = 1;
        for (int j = 0; j < N; ++j) {
            sum += cost(i, j);
        }
        B[0].flip(i);
        if (sum <= K) {
            std::cout << "DA\n";
            return 0;
        }
    }
    std::cout << "NE\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 16 ms 424 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 31 ms 376 KB Output is correct
8 Correct 106 ms 408 KB Output is correct
9 Correct 7 ms 332 KB Output is correct
10 Correct 111 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 332 KB Output is correct
2 Correct 13 ms 1040 KB Output is correct
3 Correct 9 ms 844 KB Output is correct
4 Correct 9 ms 772 KB Output is correct
5 Correct 16 ms 1216 KB Output is correct
6 Correct 38 ms 580 KB Output is correct
7 Correct 70 ms 928 KB Output is correct
8 Correct 79 ms 912 KB Output is correct
9 Correct 21 ms 460 KB Output is correct
10 Correct 123 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 332 KB Output is correct
2 Correct 14 ms 1028 KB Output is correct
3 Correct 9 ms 808 KB Output is correct
4 Correct 11 ms 936 KB Output is correct
5 Correct 12 ms 972 KB Output is correct
6 Correct 121 ms 1296 KB Output is correct
7 Correct 29 ms 584 KB Output is correct
8 Correct 65 ms 908 KB Output is correct
9 Correct 71 ms 904 KB Output is correct
10 Correct 125 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 332 KB Output is correct
2 Correct 9 ms 708 KB Output is correct
3 Incorrect 125 ms 1320 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 332 KB Output is correct
2 Correct 18 ms 1344 KB Output is correct
3 Incorrect 116 ms 1268 KB Output isn't correct
4 Halted 0 ms 0 KB -