Submission #863937

# Submission time Handle Problem Language Result Execution time Memory
863937 2023-10-21T13:35:38 Z hariaakas646 Povjerenstvo (COI22_povjerenstvo) C++17
0 / 100
242 ms 51904 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int main() {
    // usaco();
    int n, m;
    scd(n);
    scd(m);
    vvi gr(n+1), rg(n+1);
    vi outdeg(n+1);

    frange(i, m) {
        int a, b;
        scd(a);
        scd(b);
        outdeg[a]++;
        gr[a].pb(b);
        gr[b].pb(a);
    }

    vb vis(n+1);
    vb pick(n+1);
    queue<pair<int, bool>> q;

    forr(i, 1, n+1) {
        if(outdeg[i] == 0) q.push(mp(i, true));
    }

    while(q.size()) {
        auto p = q.front();
        q.pop();
        if(vis[p.f]) continue;
        vis[p.f] = true;
        pick[p.f] = p.s;

        for(auto e : gr[p.f]) {
            q.push(mp(e, !p.s));
        }
    }
    vi out;
    forr(i, 1, n+1) {
        if(pick[i]) out.pb(i);
    }
    printf("%d\n", (int)out.size());
    for(auto e : out) printf("%d ", e);
}

Compilation message

Main.cpp: In function 'void usaco()':
Main.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:37:5: note: in expansion of macro 'scd'
   37 |     scd(n);
      |     ^~~
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:38:5: note: in expansion of macro 'scd'
   38 |     scd(m);
      |     ^~~
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:44:9: note: in expansion of macro 'scd'
   44 |         scd(a);
      |         ^~~
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:45:9: note: in expansion of macro 'scd'
   45 |         scd(b);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 144 ms 42252 KB Output is correct
2 Correct 137 ms 42112 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 51 ms 33876 KB Output is correct
5 Correct 90 ms 46160 KB Output is correct
6 Correct 136 ms 50888 KB Output is correct
7 Correct 125 ms 47524 KB Output is correct
8 Correct 139 ms 49860 KB Output is correct
9 Correct 242 ms 45184 KB Output is correct
10 Incorrect 205 ms 43220 KB There must not be two people within the committee such that one person dislikes the other.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 147 ms 42380 KB Output is correct
2 Correct 141 ms 51904 KB Output is correct
3 Correct 119 ms 45068 KB Output is correct
4 Incorrect 236 ms 47164 KB There must not be two people within the committee such that one person dislikes the other.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Incorrect 2 ms 860 KB There must not be two people within the committee such that one person dislikes the other.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 42252 KB Output is correct
2 Correct 137 ms 42112 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 51 ms 33876 KB Output is correct
5 Correct 90 ms 46160 KB Output is correct
6 Correct 136 ms 50888 KB Output is correct
7 Correct 125 ms 47524 KB Output is correct
8 Correct 139 ms 49860 KB Output is correct
9 Correct 242 ms 45184 KB Output is correct
10 Incorrect 205 ms 43220 KB There must not be two people within the committee such that one person dislikes the other.
11 Halted 0 ms 0 KB -