답안 #839967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839967 2023-08-30T22:52:19 Z ariloc 봉쇄 시간 (IOI23_closing) C++17
0 / 100
80 ms 17076 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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 17076 KB 1st lines differ - on the 1st token, expected: '451', found: '181'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -