Submission #1114494

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

using i64 = long long;

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

constexpr int max_N = int(1000) + 5;

int N, M;
std::vector<int> adj[max_N], cdj[max_N];

// std::vector<int> stk;
// int tin[max_N], low[max_N], belong[max_N], siz[max_N], timer, nc;
// void dfs1(int v, int pr) {
//     stk.emplace_back(v);
//     low[v] = tin[v] = ++timer;
//     for (auto u : adj[v]) {
//         if (u == pr) {
//             continue;
//         }
//         if (low[u] == 0) {
//             dfs1(u, v);
//             low[v] = std::min(low[v], low[u]);
//         } else if (belong[u] == 0) {
//             low[v] = std::min(low[v], tin[u]);
//         }
//     }
//     if (low[v] == tin[v]) {
//         ++nc;
//         int u;
//         do {
//             u = stk.back();
//             stk.pop_back();
//             belong[u] = nc;
//             ++siz[nc - 1];
//         } while (u != v);
//     }
// }

// int dp[max_N];
// void dfs2(int v, int pr) {
//     for (auto u : adj[v]) {
//         if (u == pr) {
//             dp[]
//         }
//     }
// }

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

    std::cin >> N >> M;
    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);
    }

    // dfs1(0, 0);

    // for (int v = 0; v < N; ++v) {
    //     for (auto u : adj[v]) {
    //         if (belong[u] != belong[v]) {
    //             cdj[belong[u] - 1].emplace_back(belong[v] - 1);
    //         }
    //     }
    // }

    // dfs2(0, 0);

    for (int i = 0; i < N; ++i) {
        if (adj[i].size() == M) {
            std::cout << "YES\n";
            std::cout << "2\n";
            std::cout << i + 1 << ' ' << i + 1 << '\n';
            return 0;
        }
    }

    std::cout << "NO\n";

    return 0;
}

Compilation message

newspapers.cpp: In function 'int main()':
newspapers.cpp:79:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |         if (adj[i].size() == M) {
      |             ~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -