Submission #660358

# Submission time Handle Problem Language Result Execution time Memory
660358 2022-11-21T17:45:18 Z Dec0Dedd Information (CEOI08_information) C++14
8 / 100
593 ms 31548 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 {
            bool ok=false;
            for (auto z : GT[u.first]) {
                if (c[z.second] == 0) {
                    ok=true;
                    c[z.second]=1;
                }
            }

            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 0 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 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 0 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 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 0 ms 340 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 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 Incorrect 3 ms 560 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 7 ms 724 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 416 KB agent 14 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 Incorrect 2 ms 488 KB agent 3 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 4156 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 116 ms 7060 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 52 ms 4224 KB agent 6 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 5 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 608 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 558 ms 31280 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 495 ms 30400 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 593 ms 31548 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 4 ms 596 KB agent 6 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -