Submission #525097

# Submission time Handle Problem Language Result Execution time Memory
525097 2022-02-10T17:08:10 Z azberjibiou Firefighting (NOI20_firefighting) C++17
0 / 100
286 ms 30284 KB
#include <bits/stdc++.h>
#define gibon ios::sync_with_stdio(false); cin.tie(0);
#define fir first
#define sec second
#define pdd pair<double, double>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pmax pair<__int128, __int128>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1 , 0};
const int mxN=300005;
const int mxM=1010;
const int mxK=105;
const int MOD=1000000007;
const ll INF=1000000;
const ll P1=1000000009;
const ll P2=1000000009;
int N;
ll K;
ll station[mxN];
ll town[mxN];
bool Chk[mxN];
vector <pll> v[mxN];
int ans;
void dfs(int now, int pre, ll dis)
{
    station[now]=INF;
    town[now]=0;
    for(pll nxt : v[now])   if(nxt.fir!=pre)
    {
        dfs(nxt.fir, now, nxt.sec);
        station[now]=min(station[now], station[nxt.fir]+nxt.sec);
        town[now]=max(town[now], town[nxt.fir]+nxt.sec);
    }
    if(now==1)
    {
        if(town[now]>K-station[now])
        {
            Chk[now]=true;
            ans++;
        }
        return;
    }
    if(town[now]<=K-station[now])   town[now]=-INF;
    if(town[now]+dis>K)
    {
        Chk[now]=true;
        station[now]=0;
        town[now]=-1;
    }
}
int main()
{
    gibon
    cin >> N >> K;
    for(int i=1;i<N;i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        v[a].emplace_back(b, c);
        v[b].emplace_back(a, c);
    }
    dfs(1, -1, 0);
    cout << ans << '\n';
    for(int i=1;i<=N;i++)
    {
        if(Chk[i])  cout << i << " ";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 30276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7276 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Incorrect 3 ms 7372 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7372 KB Integer parameter [name=F] equals to 0, violates the range [1, 17]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 280 ms 30284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7500 KB Integer parameter [name=F] equals to 0, violates the range [1, 2303]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 242 ms 27300 KB Integer parameter [name=F] equals to 0, violates the range [1, 288940]
2 Halted 0 ms 0 KB -