답안 #876268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876268 2023-11-21T13:25:16 Z 8pete8 Stranded Far From Home (BOI22_island) C++14
100 / 100
91 ms 17860 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
#include <iomanip>  
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define ll long long    
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
//#define p push
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
//#pragma GCC optimize ("03,unroll-lopps")
#define int long long
const int mxn=2e5,inf=1e9;
vector<ppii>e;
int val[mxn+10],n,m,pa[mxn+10],sum[mxn+10];
bool ans[mxn+10];
int find(int u){
    if(pa[u]==u)return u;
    int k=find(pa[u]);
    ans[u]|=ans[pa[u]];
    return pa[u]=k;
}
void merg(int u,int v){
    int a=find(u),b=find(v);
    if(a==b)return;
    if(sum[b]<val[a])ans[b]=true;
    pa[b]=a,sum[a]+=sum[b];
}
int32_t main(){
    fastio
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>val[i],sum[i]=val[i],pa[i]=i;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        if(val[a]<val[b])swap(a,b);
        e.pb({val[a],{a,b}});
    }
    sort(all(e));
    for(auto i:e)merg(i.s.f,i.s.s);
    for(int i=1;i<=n;i++)find(i),cout<<(!ans[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4832 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4700 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 70 ms 16812 KB Output is correct
4 Correct 70 ms 15040 KB Output is correct
5 Correct 69 ms 15524 KB Output is correct
6 Correct 71 ms 17088 KB Output is correct
7 Correct 72 ms 15408 KB Output is correct
8 Correct 84 ms 15300 KB Output is correct
9 Correct 70 ms 15232 KB Output is correct
10 Correct 65 ms 15812 KB Output is correct
11 Correct 68 ms 16736 KB Output is correct
12 Correct 79 ms 14268 KB Output is correct
13 Correct 65 ms 17072 KB Output is correct
14 Correct 70 ms 16248 KB Output is correct
15 Correct 67 ms 15664 KB Output is correct
16 Correct 49 ms 15040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 75 ms 16064 KB Output is correct
3 Correct 78 ms 16064 KB Output is correct
4 Correct 74 ms 17860 KB Output is correct
5 Correct 72 ms 16300 KB Output is correct
6 Correct 74 ms 16580 KB Output is correct
7 Correct 70 ms 15412 KB Output is correct
8 Correct 67 ms 17024 KB Output is correct
9 Correct 48 ms 15536 KB Output is correct
10 Correct 70 ms 17104 KB Output is correct
11 Correct 68 ms 15536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 86 ms 16104 KB Output is correct
3 Correct 86 ms 16332 KB Output is correct
4 Correct 82 ms 16368 KB Output is correct
5 Correct 80 ms 15600 KB Output is correct
6 Correct 78 ms 15140 KB Output is correct
7 Correct 72 ms 17080 KB Output is correct
8 Correct 67 ms 16432 KB Output is correct
9 Correct 69 ms 13764 KB Output is correct
10 Correct 72 ms 14528 KB Output is correct
11 Correct 69 ms 15204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4832 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4700 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 70 ms 16812 KB Output is correct
18 Correct 70 ms 15040 KB Output is correct
19 Correct 69 ms 15524 KB Output is correct
20 Correct 71 ms 17088 KB Output is correct
21 Correct 72 ms 15408 KB Output is correct
22 Correct 84 ms 15300 KB Output is correct
23 Correct 70 ms 15232 KB Output is correct
24 Correct 65 ms 15812 KB Output is correct
25 Correct 68 ms 16736 KB Output is correct
26 Correct 79 ms 14268 KB Output is correct
27 Correct 65 ms 17072 KB Output is correct
28 Correct 70 ms 16248 KB Output is correct
29 Correct 67 ms 15664 KB Output is correct
30 Correct 49 ms 15040 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 75 ms 16064 KB Output is correct
33 Correct 78 ms 16064 KB Output is correct
34 Correct 74 ms 17860 KB Output is correct
35 Correct 72 ms 16300 KB Output is correct
36 Correct 74 ms 16580 KB Output is correct
37 Correct 70 ms 15412 KB Output is correct
38 Correct 67 ms 17024 KB Output is correct
39 Correct 48 ms 15536 KB Output is correct
40 Correct 70 ms 17104 KB Output is correct
41 Correct 68 ms 15536 KB Output is correct
42 Correct 1 ms 4696 KB Output is correct
43 Correct 86 ms 16104 KB Output is correct
44 Correct 86 ms 16332 KB Output is correct
45 Correct 82 ms 16368 KB Output is correct
46 Correct 80 ms 15600 KB Output is correct
47 Correct 78 ms 15140 KB Output is correct
48 Correct 72 ms 17080 KB Output is correct
49 Correct 67 ms 16432 KB Output is correct
50 Correct 69 ms 13764 KB Output is correct
51 Correct 72 ms 14528 KB Output is correct
52 Correct 69 ms 15204 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 2 ms 4608 KB Output is correct
58 Correct 1 ms 4444 KB Output is correct
59 Correct 1 ms 4444 KB Output is correct
60 Correct 1 ms 4444 KB Output is correct
61 Correct 1 ms 4572 KB Output is correct
62 Correct 1 ms 4700 KB Output is correct
63 Correct 2 ms 4700 KB Output is correct
64 Correct 1 ms 4572 KB Output is correct
65 Correct 1 ms 4700 KB Output is correct
66 Correct 1 ms 4444 KB Output is correct
67 Correct 72 ms 16324 KB Output is correct
68 Correct 66 ms 15388 KB Output is correct
69 Correct 69 ms 15816 KB Output is correct
70 Correct 73 ms 15804 KB Output is correct
71 Correct 72 ms 16052 KB Output is correct
72 Correct 81 ms 16324 KB Output is correct
73 Correct 68 ms 16304 KB Output is correct
74 Correct 68 ms 16076 KB Output is correct
75 Correct 67 ms 17380 KB Output is correct
76 Correct 72 ms 15300 KB Output is correct
77 Correct 67 ms 17644 KB Output is correct
78 Correct 73 ms 16184 KB Output is correct
79 Correct 73 ms 17092 KB Output is correct
80 Correct 53 ms 16064 KB Output is correct
81 Correct 78 ms 16616 KB Output is correct
82 Correct 74 ms 16904 KB Output is correct
83 Correct 72 ms 17848 KB Output is correct
84 Correct 67 ms 15356 KB Output is correct
85 Correct 73 ms 16584 KB Output is correct
86 Correct 67 ms 16320 KB Output is correct
87 Correct 70 ms 16204 KB Output is correct
88 Correct 69 ms 17080 KB Output is correct
89 Correct 68 ms 15272 KB Output is correct
90 Correct 91 ms 16592 KB Output is correct
91 Correct 81 ms 16576 KB Output is correct
92 Correct 82 ms 16836 KB Output is correct
93 Correct 78 ms 16576 KB Output is correct
94 Correct 78 ms 15556 KB Output is correct
95 Correct 72 ms 17076 KB Output is correct
96 Correct 61 ms 16052 KB Output is correct
97 Correct 64 ms 13760 KB Output is correct
98 Correct 70 ms 14916 KB Output is correct
99 Correct 77 ms 15612 KB Output is correct
100 Correct 47 ms 14016 KB Output is correct
101 Correct 81 ms 16832 KB Output is correct
102 Correct 75 ms 14528 KB Output is correct
103 Correct 81 ms 15812 KB Output is correct
104 Correct 80 ms 15944 KB Output is correct