답안 #601484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601484 2022-07-22T05:38:11 Z 반딧불(#8472) Stranded Far From Home (BOI22_island) C++17
0 / 100
1000 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
ll arr[200002];
ll sum[200002];
bool ans[200002];
vector<int> link[200002];

void dfs(int x, int p=-1){
    sum[x] = arr[x];
    for(auto y: link[x]){
        if(y==p) continue;
        dfs(y, x);
        sum[x] += sum[y];
    }
    if(p==-1 || arr[p] <= sum[x]) ans[x] = 1;
}

int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
    for(int i=1; i<=m; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        link[x].push_back(y);
        link[y].push_back(x);
    }

    dfs(1);
    for(int i=1; i<=n; i++) printf("%d", ans[i]);
}

Compilation message

island.cpp: In function 'int main()':
island.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
island.cpp:25:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
island.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 239 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 137 ms 20956 KB Output is correct
4 Incorrect 144 ms 21080 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Incorrect 174 ms 30232 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Execution timed out 1096 ms 371708 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 239 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -