Submission #1053954

# Submission time Handle Problem Language Result Execution time Memory
1053954 2024-08-11T23:27:18 Z HD1 Closing Time (IOI23_closing) C++17
0 / 100
100 ms 52932 KB
#include "closing.h"
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) ll(x.size())
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAX=1e6;
const ll mod=1e9+7;
ll distx[MAX], disty[MAX];
vector<ii>gfo[MAX];
vector<ii> ans;
bool vst[MAX];
void dfsx(int u, int f){
    for(auto x:gfo[u]){
        int v=x.ff;
        ll w1=x.ss;
        if(v!=f){
            distx[v]=distx[u]+w1;
            dfsx(v,u);
        }
    }
    return;
}
void dfsy(int u, int f){
    for(auto x:gfo[u]){
        int v=x.ff;
        ll w1=x.ss;
        if(v!=f){
            disty[v]=disty[u]+w1;
            dfsy(v,u);
        }
    }
    return;
}
void clen(int n){
    ans.clear();
    for(int i=0; i<=n; i++){
        gfo[i].clear();
        distx[i]=0;
        disty[i]=0;
        vst[i]=0;
    }
    return;
}
int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W){
    for(ll i=0; i<sz(U) ; i++){
        gfo[U[i]].pb({V[i],W[i]});
        gfo[V[i]].pb({U[i],W[i]});
    }
    dfsx(X,X);
    dfsy(Y,Y);
    for(int i=0; i<N; i++){
        ans.pb({distx[i], i});
        ans.pb({disty[i], i});
    }
    sort(all(ans));
    ll cont=0, sum=0;
    for(auto x:ans){
        if(!vst[x.ss])sum+=x.ff;
        else{
            sum+=abs(distx[x.ss]-disty[x.ss]);
        }
        if(sum<=K)cont++;
        else break;
    }
    clen(N);
    return cont;
}
// int main(){
//     int N,  X,  Y,  K;
//     vector<int> U, V,  W;
//     max_score(N,X,Y,K,U,V,W);
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 24924 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 100 ms 52932 KB 1st lines differ - on the 1st token, expected: '451', found: '400000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 24924 KB Output is correct
2 Incorrect 3 ms 24924 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 4 ms 24924 KB Output is correct
2 Incorrect 3 ms 24924 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 4 ms 24924 KB Output is correct
2 Incorrect 3 ms 24924 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 3 ms 24924 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 3 ms 24924 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 3 ms 24924 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 3 ms 24924 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 3 ms 24924 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -