Submission #1114515

# Submission time Handle Problem Language Result Execution time Memory
1114515 2024-11-19T06:53:14 Z vjudge1 Newspapers (CEOI21_newspapers) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>

using i64 = long long;

#ifdef DEBUG 
    #include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
    #define debug(...) void(23)
#endif

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N, M;
    std::cin >> N >> M;

    std::vector<std::vector<int>> adj(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        std::cin >> A >> B;
        --A, --B;
        adj[A].emplace_back(B);
        adj[B].emplace_back(A);
    }

    std::vector<int> dp(1 << N, -1);
    dp[0] = 0;
    auto dfs = [&](auto&& self, int mask) -> int {
        if (dp[mask] != -1) {
            return dp[mask] == -2 ? 10 * N : dp[mask];
        }
        dp[mask] = -2;
        int ans = 10 * N;
        for (int i = 0; i < N; ++i) {
            int nmask = 0;
            for (int j = 0; j < N; ++j) {
                if (mask >> j & 1 && i != j) {
                    for (auto u : adj[j]) {
                        nmask |= (1 << u);
                    }
                }
            }
            debug(mask, nmask);
            ans = std::min(ans, self(self, nmask) + 1);
        }
        return dp[mask] = ans;
    };
    int ans = dfs(dfs, (1 << N) - 1);

    if (ans >= 10 * N) {
        std::cout << "NO\n";
    } else {
        std::cout << "YES\n";
        std::cout << ans << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -