답안 #993631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993631 2024-06-06T09:03:22 Z amine_aroua Stranded Far From Home (BOI22_island) C++17
10 / 100
776 ms 524288 KB
#include<bits/stdc++.h>
#pragma GCC optmize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define int long long
#define pb push_back
#define fore(i , n) for(int i = 0 ; i<n;i++)
#define forr(i , x , y) for(int i = x ; i <= y; i++)
#define forn(i , x , y) for(int i = x ; i >= y; i--)
const int N = 2e5 + 10;
vector<int> adj[N];
int a[N];
int n , m;
vector<int> ans(N , 0);
int sz[N];
void dfsSZ(int x , int p)
{
    sz[x] = a[x];
    for(auto u : adj[x])
    {
        if(u == p)
            continue;
        dfsSZ(u , x);
        sz[x]+=sz[u];
    }
}
void dfsCompute(int x , int p)
{
    for(auto u : adj[x])
    {
        if(u == p)
            continue;
        if(sz[u] >= a[x])
        {
            ans[u] = 1;
            dfsCompute(u , x);
        }
    }
}
signed main()
{
    cin>>n>>m;
    fore(i , n)
    {
        cin>>a[i];
    }
    fore(i , m)
    {
        int u , v;
        cin>>u>>v;
        u-- , v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfsSZ(0 , -1);
    ans[0] = 1;
    dfsCompute(0 , -1);
    fore(i , n)
        cout<<ans[i];
}

Compilation message

island.cpp:2: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
    2 | #pragma GCC optmize("O3")
      |
# 결과 실행 시간 메모리 Grader output
1 Runtime error 342 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9564 KB Output is correct
2 Correct 2 ms 9564 KB Output is correct
3 Correct 180 ms 27780 KB Output is correct
4 Correct 136 ms 26452 KB Output is correct
5 Correct 169 ms 21332 KB Output is correct
6 Correct 169 ms 21544 KB Output is correct
7 Correct 213 ms 21644 KB Output is correct
8 Correct 179 ms 21804 KB Output is correct
9 Correct 172 ms 22756 KB Output is correct
10 Correct 130 ms 21184 KB Output is correct
11 Correct 144 ms 21140 KB Output is correct
12 Correct 127 ms 20304 KB Output is correct
13 Correct 131 ms 34644 KB Output is correct
14 Correct 132 ms 34972 KB Output is correct
15 Correct 165 ms 36176 KB Output is correct
16 Correct 143 ms 35364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9564 KB Output is correct
2 Incorrect 170 ms 36136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9564 KB Output is correct
2 Runtime error 776 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 342 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -