답안 #1091473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091473 2024-09-21T00:01:20 Z tfgs Sajam (COCI18_sajam) C++17
45 / 90
58 ms 1640 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#endif

#define f first
#define s second
template<class T> using V = vector<T>; 
using vi = V<int>;
using vb = V<bool>;
using vs = V<string>;

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x) 
#define len(x) (int)((x).size())
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T> int lwb(V<T>& a, const T& b) { return lb(all(a),b)-begin(a); }
template<class T> int upb(V<T>& a, const T& b) { return ub(all(a),b)-begin(a); }
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a=b, true : false; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a=b, true : false; }
#define pct __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
constexpr int p2(int x) { return (int)1 << x; }
constexpr int bits(int x) { return x == 0 ? 0 : 31-clz(x); } // floor(log2(x)) 

const int N = 1000;
bitset<N> row[N], col[N];

void solve() {
    int n, k; cin >> n >> k;

    if (n == 1) {
        cout << "DA\n";
        return;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c; cin >> c;
            if (c == 'o') {
                row[i].set(j);
                col[j].set(i);
            }
        }
    }

    if (k == n) {
        bool is_perm = true;
        for (int i = 0; i < n; i++) {
            row[0].flip(i);

            for (int j = 1; j < n; j++) {
                int cnt = (row[j]^row[0]).count();
                is_perm &= cnt == 1 || cnt+1 == n;
            }

            row[0].flip(i);
        }
    }

    for (int i = 0; i < n; i++) {
        int cost = 0;
        for (int j = 0; j < n; j++) if (j != i) {
            int cnt = (row[i]^row[j]).count();
            cost += min(cnt, n-cnt);
        }
        if (cost <= k) {
            cout << "DA\n";
            return;
        }
    }
    cout << "NE\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Correct 9 ms 1480 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 14 ms 840 KB Output is correct
8 Correct 49 ms 1528 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 57 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1196 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
3 Correct 5 ms 960 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 8 ms 1488 KB Output is correct
6 Correct 15 ms 868 KB Output is correct
7 Correct 29 ms 1116 KB Output is correct
8 Correct 31 ms 1116 KB Output is correct
9 Correct 10 ms 600 KB Output is correct
10 Correct 56 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1368 KB Output is correct
2 Correct 7 ms 1220 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 1112 KB Output is correct
5 Correct 5 ms 1116 KB Output is correct
6 Correct 49 ms 1620 KB Output is correct
7 Correct 12 ms 604 KB Output is correct
8 Correct 28 ms 1156 KB Output is correct
9 Correct 33 ms 1220 KB Output is correct
10 Correct 58 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Incorrect 52 ms 1640 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1480 KB Output is correct
2 Correct 9 ms 1612 KB Output is correct
3 Incorrect 45 ms 1368 KB Output isn't correct
4 Halted 0 ms 0 KB -