답안 #904520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
904520 2024-01-12T05:39:49 Z abcvuitunggio 봉쇄 시간 (IOI23_closing) C++17
0 / 100
281 ms 51600 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
vector <pair <int, int>> ke[200001];
vector <int> child[200001][2];
long long d[200001][2];
int p[200001][2],ch[200001][2],waiting[200001][2];
priority_queue <pair <int, pair <int, int>>, vector <pair <int, pair <int, int>>>, greater <pair <int, pair <int, int>>>> q;
void dfs(int u, int par, int i){
    for (auto [v,w]:ke[u])
        if (v!=par){
            child[u][i].push_back(v);
            d[v][i]=d[u][i]+w;
            p[v][i]=u;
            dfs(v,u,i);
        }
}
void dfs2(int u, int i){
    for (int v:child[u][i])
        if (waiting[v][i]){
            waiting[v][i]=0;
            q.push({d[v][i],{v,i}});
            dfs2(v,i);
        }
}
int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W){
    for (int i=0;i<N-1;i++){
        ke[U[i]].push_back({V[i],W[i]});
        ke[V[i]].push_back({U[i],W[i]});
    }
    d[X][0]=d[Y][1]=0;
    memset(ch,0,sizeof(ch));
    memset(waiting,0,sizeof(waiting));
    dfs(X,X,0);
    dfs(Y,Y,1);
    for (int i=0;i<N;i++)
        if (d[i][0]<d[i][1])
            q.push({d[i][0],{i,0}});
        else
            q.push({d[i][1],{i,1}});
    long long sum=0;
    int res=0;
    while (!q.empty()){
        auto [w,v]=q.top();
        q.pop();
        if (sum+w>K)
            break;
        sum+=w;
        res++;
        auto [u,i]=v;
        ch[u][i]=1;
        if (!ch[u][i^1]){
            if (!ch[p[u][i^1]][i^1])
                waiting[u][i^1]=1;
            else
                q.push({d[u][i^1]-d[u][i],{u,i^1}});
        }
        dfs2(u,i);
    }
    for (int i=0;i<N;i++){
        ke[i].clear();
        child[i][0].clear();
        child[i][1].clear();
    }
    while (!q.empty())
        q.pop();
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 281 ms 51600 KB 1st lines differ - on the 1st token, expected: '451', found: '212796'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Correct 6 ms 22108 KB Output is correct
3 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Correct 6 ms 22108 KB Output is correct
3 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Correct 6 ms 22108 KB Output is correct
3 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Correct 6 ms 22108 KB Output is correct
3 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22108 KB Output is correct
2 Correct 6 ms 22108 KB Output is correct
3 Incorrect 6 ms 22108 KB 1st lines differ - on the 1st token, expected: '30', found: '28'
4 Halted 0 ms 0 KB -