Submission #839968

# Submission time Handle Problem Language Result Execution time Memory
839968 2023-08-30T22:53:03 Z ariloc Closing Time (IOI23_closing) C++17
8 / 100
71 ms 17080 KB
#include <bits/stdc++.h>

#define forn(i,n) for(int i = 0; i < int(n); i++)
#define forsn(i,s,n) for(int i = int(s); i < int(n); i++)
#define dforn(i,n) for (int i = int(n)-1; i >= 0; i--)
#define dforsn(i,s,n) for(int i = int(n)-1; i >= int(s); i--)
#define dbg(x) cerr << #x << " = " << x << endl;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fst first
#define snd second
#define FAST_IO ios::sync_with_stdio(false);cin.tie(nullptr);
 
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

int const MAXN = 2e5+5;

struct nod {
    int v;
    ll w;
    bool orig;

    nod(int a, ll b, bool c) : v(a), w(b), orig(c){}

    bool operator< (const nod &o) const {
        return w > o.w;
    }
};

struct edges {
    int v,w;
};

bitset<MAXN> done[2];
vector<edges> G[MAXN];

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    forn(i,N) done[0][i] = done[1][i] = false, G[i].clear();

    forn(i,N-1) {
        G[U[i]].pb({V[i], W[i]});
        G[V[i]].pb({U[i], W[i]});
    }

    int rta = 0;
    priority_queue<nod> Q;
    Q.push({X,0,0}); done[0][X] = true;
    Q.push({Y,0,1}); done[1][Y] = true;

    while (!Q.empty() && Q.top().w <= K) {
        auto e = Q.top(); Q.pop();

        K -= e.w;
        ++rta;

        for (auto &i : G[e.v]) {
            if (done[e.orig][i.v]) continue;
            done[e.orig][i.v] = true;
            Q.push(nod(i.v,e.w+i.w,e.orig));
        }
    }

    return rta;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 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 71 ms 17080 KB Output is correct
2 Correct 69 ms 16704 KB Output is correct
3 Correct 46 ms 7360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 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 2 ms 4948 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 2 ms 4948 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 2 ms 4948 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 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -