Submission #601483

# Submission time Handle Problem Language Result Execution time Memory
601483 2022-07-22T05:37:04 Z 반딧불(#8472) Stranded Far From Home (BOI22_island) C++17
0 / 100
368 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];

bool 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 'bool dfs(int, int)':
island.cpp:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 368 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 10076 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 10068 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 10072 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 368 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -