Submission #660362

# Submission time Handle Problem Language Result Execution time Memory
660362 2022-11-21T17:48:57 Z Dec0Dedd Information (CEOI08_information) C++14
41 / 100
450 ms 20672 KB
#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>

const int N = 2e3+1;
const int M = 1e6+1;

int c[M], n, m;
bool vis[N];
vector<pii> G[N], GT[N];

void dfs(int v) {
    vis[v]=true;
    for (auto u : G[v]) {
        if (vis[u.first]) continue;
        c[u.second]=1, dfs(u.first);
    }
}

void dfs2(int v) {
    vis[v]=true;
    for (auto u : G[v]) {
        if (vis[u.first]) continue;
        if (c[u.second] == 0) {
            c[u.second]=2; dfs2(u.first);
        } else { assert(c[u.second] == 1);
            bool ok=false;
            for (auto z : GT[u.first]) {
                if (c[z.second] == 0) {
                    ok=true;
                    c[z.second]=1;
                    break;
                }
            }

            if (ok) {
                c[u.second]=2;
                dfs2(u.first);
            }
        }
    }
}

int main() {
    cin>>n>>m;
    for (int i=1; i<=m; ++i) {
        int a, b; cin>>a>>b;
        G[a].push_back({b, i});
        GT[b].push_back({a, i});
    } dfs(1);
    memset(vis, false, sizeof(vis));
    dfs2(1);

    vector<int> l, r;
    for (int i=1; i<=m; ++i) {
        if (c[i] == 1) l.push_back(i);
        else if (c[i] == 2) r.push_back(i);
    }

    if ((int)l.size() < n-1 || (int)r.size() < n-1) cout<<"NONE\n";
    else {
        for (auto u : l) cout<<u<<" ";
        cout<<"\n";
        for (auto u : r) cout<<u<<" ";
        cout<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB agent 5 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB agent 2 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB agent 7 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB agent 3 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 668 KB agent 2 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB agent 12 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB agent 21 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB agent 8 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 3284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 4988 KB agent 2 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 3420 KB agent 6 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB agent 9 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 450 ms 20596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 390 ms 20128 KB agent 318 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 444 ms 20672 KB agent 2 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB agent 6 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -