Submission #436123

# Submission time Handle Problem Language Result Execution time Memory
436123 2021-06-24T09:10:43 Z two_sides Toy Train (IOI17_train) C++17
0 / 100
76 ms 1988 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> who_wins(vector<int> own,
vector <int> imp, vector<int> from, vector<int> to) {
    int n = own.size(), m = from.size();
    vector<int> deg(n), cnt(n), win(n);
    vector<vector<int>> adj(n);
    queue <int> que;
    for (int i = 0; i < m; i++) {
        adj[to[i]].push_back(from[i]);
        deg[from[i]]++;
    }
    for (bool flag = 1; flag; ) {
        fill(cnt.begin(), cnt.end(), 0);
        fill(win.begin(), win.end(), 0);
        for (int i = 0; i < n; i++)
            if (imp[i]) {
                que.push(i); win[i] = 1;
            }
        while (que.size()) {
            int u = que.front(); que.pop();
            for (int v : adj[u]) {
                if (win[v]) continue;
                if (own[v]) {
                    win[v] = 1; que.push(v);
                } else if (++cnt[v] == deg[v]) {
                    win[v] = 1; que.push(v);
                }
            }
        }
        flag = 0;
        for (int i = 0; i < n; i++)
            if (!win[i]) que.push(i);
        while (que.size()) {
            int u = que.front(); que.pop();
            if (imp[u]) {
                flag = true; imp[u] = 0;
            }
            for (int v : adj[u]) {
                if (!win[v]) continue;
                if (!own[v]) {
                    win[v] = 0; que.push(v);
                } else if (++cnt[v] == deg[v]) {
                    win[v] = 0; que.push(v);
                }
            }
        }
    }
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:51:1: warning: no return statement in function returning non-void [-Wreturn-type]
   51 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 1988 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 1944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -