답안 #1078921

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078921 2024-08-28T08:09:48 Z LIF Stranded Far From Home (BOI22_island) C++14
0 / 100
1000 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;
int head[500005];
int cnt = 0;
long long int a[500005];
int last[500005];
long long int siz[500005];
struct edg
{
    int to;
    int next;
}edge[500005];
void add(int x,int y)
{
    cnt++;
    edge[cnt].to = y;
    edge[cnt].next = head[x];
    head[x] = cnt;
}
void dfs(int now,int fa)
{
    siz[now] = a[now];
    for(int i=head[now];i!=0;i=edge[i].next)
    {
        int to = edge[i].to;
        if(to == fa)continue;
        dfs(to,now);
        siz[now] += siz[to];
    }
    if(siz[now] >= a[fa])last[now] = 1;
    return;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        add(x,y);
        add(y,x);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)cout<<last[i];
    cout<<endl;




    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 325 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 137 ms 18924 KB Output is correct
4 Incorrect 112 ms 17608 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 144 ms 26492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1102 ms 389480 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 325 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -