Submission #974591

# Submission time Handle Problem Language Result Execution time Memory
974591 2024-05-03T13:42:11 Z onlk97 Keys (IOI21_keys) C++17
9 / 100
3000 ms 22868 KB
#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector <int> find_reachable(vector <int> r,vector <int> u,vector <int> v,vector <int> c){
    int n=r.size(),m=u.size();
    vector <pair <int,int> > g[n];
    for (int i=0; i<m; i++){
        g[u[i]].push_back({v[i],c[i]});
        g[v[i]].push_back({u[i],c[i]});
    }
    vector <int> p,w[n];
    bool have[n],visited[n];
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++) w[j].clear();
        for (int j=0; j<n; j++) have[j]=0;
        for (int j=0; j<n; j++) visited[j]=0;
        queue <int> q;
        q.push(i);
        have[r[i]]=1;
        visited[i]=1;
        while (!q.empty()){
            int tp=q.front(); q.pop();
            for (auto j:g[tp]){
                if (visited[j.first]) continue;
                if (have[j.second]){
                    visited[j.first]=1;
                    q.push(j.first);
                    if (!have[r[j.first]]){
                        for (int k:w[r[j.first]]){
                            if (!visited[k]){
                                q.push(k);
                                visited[k]=1;
                            }
                        }
                    }
                    have[r[j.first]]=1;
                } else w[j.second].push_back(j.first);
            }
        }
        int cnt=0;
        for (int j=0; j<n; j++){
            if (visited[j]) cnt++;
        }
        p.push_back(cnt);
    }
    int mn=*min_element(p.begin(),p.end());
    vector <int> ans(n,0);
    for (int i=0; i<n; i++){
        if (p[i]==mn) ans[i]=1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Execution timed out 3016 ms 22868 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -