답안 #988583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988583 2024-05-25T08:19:11 Z Gray 봉쇄 시간 (IOI23_closing) C++17
17 / 100
91 ms 31816 KB
#include "closing.h"

#include <bits/stdc++.h>
#include <functional>
#include <queue>
#define ll long long
#define ff first
#define ss second
#define ln endl
using namespace std;
vector<vector<int>> A;
ll n, x, y, k;
vector<pair<ll, pair<ll, ll>>> edge;
ll dijkstra(){
    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> que;
    que.push({0, {x, 0}});
    que.push({0, {y, 1}});
    vector<vector<ll>> reachable(n, vector<ll>(2, -1));

    while (!que.empty()){
        auto cur = que.top();
        que.pop();
        if (reachable[cur.ss.ff][cur.ss.ss]!=-1){
            continue;
        }
        if (reachable[cur.ss.ff][cur.ss.ss^1]!=-1){
            if (k+reachable[cur.ss.ff][cur.ss.ss^1]-cur.ff<0) continue;
        }else{
            if (k<cur.ff) continue;
        }
        // cout << cur.ss << ln;
        if (reachable[cur.ss.ff][cur.ss.ss^1]!=-1) k+=reachable[cur.ss.ff][cur.ss.ss^1];
        reachable[cur.ss.ff][cur.ss.ss]=cur.ff;
        k-=cur.ff;
        for (auto i:A[cur.ss.ff]){
            auto v = edge[i].ss.ff^edge[i].ss.ss^cur.ss.ff;
            if (reachable[v][cur.ss.ss]!=-1) continue;
            if (reachable[v][cur.ss.ss^1]!=-1){
                if (k+reachable[v][cur.ss.ss^1]<cur.ff+edge[i].ff) continue;
            }else{
                if (k<cur.ff+edge[i].ff) continue;
            }
            que.push({cur.ff+edge[i].ff, {v, cur.ss.ss}});
        }
    }
    ll ans=0;
    for (ll i=0; i<n; i++) {
        if (reachable[i][0]!=-1) {
            ans++;
        }
        if (reachable[i][1]!=-1){
            ans++;
        }
    }
    return ans;
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    A.assign(N, vector<int>());
    edge.resize(N-1);
    n=N; x=X; y=Y; k=K;
    for (ll i=0; i<n-1; i++){
        A[U[i]].push_back(i);
        A[V[i]].push_back(i);
        edge[i]={W[i],{V[i], U[i]}};
    }
    return dijkstra();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 31816 KB Output is correct
2 Correct 91 ms 31572 KB Output is correct
3 Correct 50 ms 3200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '17'
15 Halted 0 ms 0 KB -