Submission #1000468

# Submission time Handle Problem Language Result Execution time Memory
1000468 2024-06-17T14:34:24 Z Mardonbekhazratov Closing Time (IOI23_closing) C++17
0 / 100
60 ms 21700 KB
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#include "closing.h"
#include <queue>
#include <vector>

using namespace std;

#define ff first
#define ss second
#define mp make_pair


vector<vector<pair<int,long long>>>v;
vector<bool>vis1,vis2;
vector<long long>c;

int max_score(int N, int X, int Y, long long K,
              vector<int> U, vector<int> V, vector<int> W){
    v.assign(N,vector<pair<int,long long>>(0));
    vis1.assign(N,false);
    vis2.assign(N,false);
    for(int i=0;i<N-1;i++){
        v[U[i]].push_back({V[i],W[i]});
        v[V[i]].push_back({U[i],W[i]});
    }
    c.assign(N,0);
    priority_queue<pair<pair<long long,long long>,pair<int,int>>>q;
    int ans=2;
    vis1[X]=true;
    vis2[Y]=true;
    for(auto [z,w]:v[X]) q.push({{-w,-w},{z,1}});
    for(auto [z,w]:v[Y]) q.push({{-w,-w},{z,2}});
    while(!q.empty()){
        auto [d,y]=q.top();
        int x=y.ff,id=y.ss;
        q.pop();
        if(K+d.ff<0){
            break;
        }
        c[x]=max(c[x],-d.ss);
        K+=d.ff;
        if(id==1) vis1[x]=true;
        else vis2[x]=true;
        ans++;
        if((id&1 && x==Y) || (id&2 && x==X)) ans--;
        for(auto [z,w]:v[x]){
            if(id==1 && !vis1[z]){
                q.push(mp(mp(min(0LL,d.ss+c[z]),d.ss-w),mp(z,id)));
            }
            if(id==2 && !vis2[z]){
                q.push(mp(mp(min(0LL,d.ss+c[z]),d.ss-w),mp(z,id)));
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 60 ms 21700 KB 1st lines differ - on the 1st token, expected: '451', found: '453'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '29'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '29'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '29'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -