답안 #848352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848352 2023-09-12T08:19:33 Z Alora Stranded Far From Home (BOI22_island) C++17
0 / 100
142 ms 28720 KB
#include <bits/stdc++.h>
#define name "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, ll>
#define getbit(i, j) ((i >> j) & 1)
#define pb push_back
#define all(v) v.begin(), v.end()
#define maxn 200005
const int M = 1e9 + 7;
using namespace std;
mt19937_64 rng(time(0));
int n, m, root[maxn], sz[maxn], ans[maxn], xd[maxn];
pii a[maxn];
vector <int> g[maxn], f[maxn];

int get(int u){
    if(root[u] == 0) return u;
    return (root[u] = get(root[u]));
}

void dfs(int u, int ok){
    ans[u] &= ok;
    for(auto v: f[u]) dfs(v, ans[u]);
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
//	freopen(name".inp","r",stdin);
//	freopen(name".out","w",stdout);
    cin >> n >> m;
    fi(i, 1, n){
        int x; cin >> x;
        a[i] = {x, i};
        sz[i] = x;
    }
    fi(i, 1, m){
        int u, v; cin >> u >> v;
        g[u].pb(v); g[v].pb(u);
    }
    sort(a + 1, a + n + 1);
    fi(i, 1, n) ans[i] = 1;
    fi(i, 1, n){
        auto [w, u] = a[i];
        for(auto v: g[u]) if(xd[v]){
            int x = get(v);
            if(x == u) continue;
            f[u].pb(x);
            root[x] = u;
            sz[u] += sz[x];
            if(sz[x] < w) ans[x] = 0;
        }
        xd[u] = 1;
    }
    dfs(a[n].se, 1);
    fi(i, 1, n) cout << ans[i];
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 13044 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Incorrect 3 ms 12892 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Incorrect 98 ms 28720 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Incorrect 123 ms 26632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Incorrect 142 ms 26824 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 13044 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Incorrect 3 ms 12892 KB Output isn't correct
5 Halted 0 ms 0 KB -