Submission #660326

# Submission time Handle Problem Language Result Execution time Memory
660326 2022-11-21T16:08:00 Z Dec0Dedd Information (CEOI08_information) C++14
42 / 100
1000 ms 9580 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=100, 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 Incorrect 1 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
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 340 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 21 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 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 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 1716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 9380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 9216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 9580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 4 ms 392 KB Output is correct