Submission #660327

# Submission time Handle Problem Language Result Execution time Memory
660327 2022-11-21T16:08:39 Z Dec0Dedd Information (CEOI08_information) C++14
58 / 100
892 ms 9572 KB
#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>

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

bool us[M], vis[N];
vector<pii> G[N];
vector<int> l, r;
int n, m;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

void dfs(int v) {
    vis[v]=true;

    shuffle(G[v].begin(), G[v].end(), rng);
    for (auto u : G[v]) {
        if (vis[u.first]) continue;
        us[u.second]=true; l.push_back(u.second);
        dfs(u.first);
    }
}

void dfs2(int v) {
    vis[v]=true;

    shuffle(G[v].begin(), G[v].end(), rng);
    for (auto u : G[v]) {
        if (vis[u.first] || us[u.second]) continue;
        r.push_back(u.second), dfs2(u.first);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m;
    for (int i=1; i<=m; ++i) {
        int a, b; cin>>a>>b;
        G[a].push_back({b, i});
    }

    int t=50, xr=0;
    while (t--) {
        memset(vis, false, sizeof(vis));
        dfs(1);
        memset(vis, false, sizeof(vis));
        dfs2(1);

        xr=max(xr, (int)r.size());
        if ((int)l.size() == n-1 && (int)r.size() == n-1) break;
        l.clear(), r.clear();
    }

    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 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 1716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 159 ms 9316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 9276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 892 ms 9572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -