Submission #858194

# Submission time Handle Problem Language Result Execution time Memory
858194 2023-10-07T14:57:52 Z Danilo21 Closing Time (IOI23_closing) C++17
8 / 100
78 ms 40276 KB
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 2e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, x, y, k, a[mxN];
vector<array<ll, 2> > g[mxN];
bool vis[mxN];

int BFS(const vector<int>& sources){

    priority_queue<array<ll, 2>,
            vector<array<ll, 2> >,
            greater<array<ll, 2> > > pq;
    for (int s : sources){
        pq.push({0, s});
        vis[s] = 1;
    }
    int cnt = 0;
    ll sum = 0;
    while (pq.size()){
        auto [d, s] = pq.top(); pq.pop();
        if (sum + d > k) break;
        sum += d;
        cnt++;
        for (auto [u, w] : g[s]){
            if (!vis[u]){
                pq.push({d + w, u});
                vis[u] = 1;
            }
        }
    }
    return cnt;
}

int Solve1(){ return BFS({x, y}); }

int Next(int s, int p){

    for (auto [u, w] : g[s])
        if (u^p) return u;
    return -1;
}

int Solve2(){

    int s = 0;
    for (; s < n; s++)
        if (g[s].size() == 1)
            break;

    return -1;
}

int Solve3(){

    return -1;
}

ll Dist(int s, int p, ll d){

    if (s == y) return d;
    ll dist = 0;
    for (auto [u, w] : g[s])
        if (u^p) smax(dist, Dist(u, s, d + w));
    return dist;
}

int Solve(){

    return Solve1();
    if (Dist(x, -1, 0) > 2*k) return Solve1();
    int mx = 0;
    for (int i = 0; i < n; i++)
        smax(mx, (int)g[i].size());
    if (mx <= 2) return Solve2();
    return Solve3();
}

int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W){

    n = N; k = K;
    x = X; y = Y;
    for (int i = 0; i < n-1; i++){
        g[U[i]].pb({V[i], W[i]});
        g[V[i]].pb({U[i], W[i]});
    }
    int ans = Solve();
    for (int i = 0; i < n; i++){
        g[i].clear();
        vis[i] = 0;
    }
    return ans;
}

Compilation message

closing.cpp: In function 'int Solve1()':
closing.cpp:64:27: warning: narrowing conversion of 'x' from 'long long int' to 'int' [-Wnarrowing]
   64 | int Solve1(){ return BFS({x, y}); }
      |                           ^
closing.cpp:64:27: warning: narrowing conversion of 'x' from 'long long int' to 'int' [-Wnarrowing]
closing.cpp:64:30: warning: narrowing conversion of 'y' from 'long long int' to 'int' [-Wnarrowing]
   64 | int Solve1(){ return BFS({x, y}); }
      |                              ^
closing.cpp:64:30: warning: narrowing conversion of 'y' from 'long long int' to 'int' [-Wnarrowing]
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 40272 KB Output is correct
2 Correct 78 ms 40276 KB Output is correct
3 Correct 49 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 24920 KB Output is correct
2 Incorrect 5 ms 24924 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 24920 KB Output is correct
2 Incorrect 5 ms 24924 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 24920 KB Output is correct
2 Incorrect 5 ms 24924 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 25052 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -