Submission #975047

# Submission time Handle Problem Language Result Execution time Memory
975047 2024-05-04T10:37:57 Z vjudge1 Stranded Far From Home (BOI22_island) C++17
100 / 100
100 ms 12700 KB
#include<bits/stdc++.h>
using namespace std;
const int NN=2e5+1;
long long node[NN],sum[NN];
int par[NN];
bitset<NN> ans;
int fp(int i){
    if(i==par[i]) return i;
    int p=fp(par[i]);
    if(!ans[par[i]]) ans[i]=ans[par[i]];
    par[i]=p;
    return p;
}
struct edl
{
    int a,b;
    bool operator < (const edl &rhs) const{
        return max(node[a],node[b])<max(node[rhs.a],node[rhs.b]);
    }
};
vector<edl> v;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {cin>>node[i],par[i]=i; sum[i]=node[i];}
    while(m--){
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    ans.set();
    for(auto i:v){
        int p1=fp(i.a);
        int p2=fp(i.b);
        if(p1==p2) continue;
        // cout<<p1<<" "<<p2<<"\n";
        if(node[p1]<node[p2]) swap(p1,p2);
        if(node[p1]>sum[p2]) ans[p2]=0;
        par[p2]=p1;
        sum[p1]+=sum[p2];
    }
    for(int i=1;i<=n;i++){
        fp(i);
        cout<<ans[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2568 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2524 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 71 ms 6528 KB Output is correct
4 Correct 58 ms 9168 KB Output is correct
5 Correct 72 ms 10184 KB Output is correct
6 Correct 74 ms 10568 KB Output is correct
7 Correct 81 ms 10632 KB Output is correct
8 Correct 65 ms 10500 KB Output is correct
9 Correct 70 ms 10440 KB Output is correct
10 Correct 69 ms 9676 KB Output is correct
11 Correct 75 ms 11024 KB Output is correct
12 Correct 59 ms 9088 KB Output is correct
13 Correct 56 ms 9156 KB Output is correct
14 Correct 57 ms 9332 KB Output is correct
15 Correct 79 ms 10696 KB Output is correct
16 Correct 52 ms 9968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 82 ms 6408 KB Output is correct
3 Correct 77 ms 10696 KB Output is correct
4 Correct 66 ms 10596 KB Output is correct
5 Correct 63 ms 9192 KB Output is correct
6 Correct 81 ms 10488 KB Output is correct
7 Correct 76 ms 10596 KB Output is correct
8 Correct 76 ms 10628 KB Output is correct
9 Correct 52 ms 9928 KB Output is correct
10 Correct 60 ms 9812 KB Output is correct
11 Correct 65 ms 9156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 73 ms 6388 KB Output is correct
3 Correct 73 ms 10660 KB Output is correct
4 Correct 74 ms 10692 KB Output is correct
5 Correct 71 ms 10648 KB Output is correct
6 Correct 68 ms 10248 KB Output is correct
7 Correct 73 ms 12700 KB Output is correct
8 Correct 60 ms 9376 KB Output is correct
9 Correct 54 ms 7812 KB Output is correct
10 Correct 62 ms 9160 KB Output is correct
11 Correct 72 ms 9160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2568 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2524 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 71 ms 6528 KB Output is correct
18 Correct 58 ms 9168 KB Output is correct
19 Correct 72 ms 10184 KB Output is correct
20 Correct 74 ms 10568 KB Output is correct
21 Correct 81 ms 10632 KB Output is correct
22 Correct 65 ms 10500 KB Output is correct
23 Correct 70 ms 10440 KB Output is correct
24 Correct 69 ms 9676 KB Output is correct
25 Correct 75 ms 11024 KB Output is correct
26 Correct 59 ms 9088 KB Output is correct
27 Correct 56 ms 9156 KB Output is correct
28 Correct 57 ms 9332 KB Output is correct
29 Correct 79 ms 10696 KB Output is correct
30 Correct 52 ms 9968 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 82 ms 6408 KB Output is correct
33 Correct 77 ms 10696 KB Output is correct
34 Correct 66 ms 10596 KB Output is correct
35 Correct 63 ms 9192 KB Output is correct
36 Correct 81 ms 10488 KB Output is correct
37 Correct 76 ms 10596 KB Output is correct
38 Correct 76 ms 10628 KB Output is correct
39 Correct 52 ms 9928 KB Output is correct
40 Correct 60 ms 9812 KB Output is correct
41 Correct 65 ms 9156 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 73 ms 6388 KB Output is correct
44 Correct 73 ms 10660 KB Output is correct
45 Correct 74 ms 10692 KB Output is correct
46 Correct 71 ms 10648 KB Output is correct
47 Correct 68 ms 10248 KB Output is correct
48 Correct 73 ms 12700 KB Output is correct
49 Correct 60 ms 9376 KB Output is correct
50 Correct 54 ms 7812 KB Output is correct
51 Correct 62 ms 9160 KB Output is correct
52 Correct 72 ms 9160 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2392 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2524 KB Output is correct
59 Correct 2 ms 2404 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 1 ms 2392 KB Output is correct
67 Correct 82 ms 10512 KB Output is correct
68 Correct 57 ms 9360 KB Output is correct
69 Correct 73 ms 10184 KB Output is correct
70 Correct 82 ms 10584 KB Output is correct
71 Correct 85 ms 10600 KB Output is correct
72 Correct 71 ms 10536 KB Output is correct
73 Correct 70 ms 10388 KB Output is correct
74 Correct 59 ms 9676 KB Output is correct
75 Correct 66 ms 10852 KB Output is correct
76 Correct 67 ms 9140 KB Output is correct
77 Correct 55 ms 9040 KB Output is correct
78 Correct 66 ms 9172 KB Output is correct
79 Correct 73 ms 10696 KB Output is correct
80 Correct 54 ms 9940 KB Output is correct
81 Correct 96 ms 10448 KB Output is correct
82 Correct 79 ms 10700 KB Output is correct
83 Correct 74 ms 10696 KB Output is correct
84 Correct 62 ms 9156 KB Output is correct
85 Correct 81 ms 10700 KB Output is correct
86 Correct 78 ms 10588 KB Output is correct
87 Correct 73 ms 10568 KB Output is correct
88 Correct 65 ms 9852 KB Output is correct
89 Correct 68 ms 9296 KB Output is correct
90 Correct 73 ms 10560 KB Output is correct
91 Correct 83 ms 10440 KB Output is correct
92 Correct 74 ms 10628 KB Output is correct
93 Correct 67 ms 10700 KB Output is correct
94 Correct 76 ms 10504 KB Output is correct
95 Correct 65 ms 12484 KB Output is correct
96 Correct 65 ms 9412 KB Output is correct
97 Correct 56 ms 7848 KB Output is correct
98 Correct 62 ms 9156 KB Output is correct
99 Correct 59 ms 9156 KB Output is correct
100 Correct 42 ms 6140 KB Output is correct
101 Correct 100 ms 10708 KB Output is correct
102 Correct 71 ms 9676 KB Output is correct
103 Correct 90 ms 9944 KB Output is correct
104 Correct 86 ms 10524 KB Output is correct