Submission #840904

# Submission time Handle Problem Language Result Execution time Memory
840904 2023-08-31T20:45:41 Z HD1 Closing Time (IOI23_closing) C++17
0 / 100
129 ms 48320 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, ll> ii;
const int MAX=1e6;
const ll mod=1e9+7;
ll distx[MAX], disty[MAX];
vector<ii>gfo[MAX];
vector<ll> ans;
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;
    }
    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]);
        ans.pb(disty[i]);
    }
    sort(all(ans));
    int cont=0, sum=0;
    for(int x:ans){
        sum+=x;
        if(sum<=K)cont++;
    }
    clen(N);
    return cont;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 23888 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 129 ms 48320 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 9 ms 23764 KB Output is correct
2 Incorrect 10 ms 23768 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 9 ms 23764 KB Output is correct
2 Incorrect 10 ms 23768 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 9 ms 23764 KB Output is correct
2 Incorrect 10 ms 23768 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 10 ms 23888 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 10 ms 23888 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 10 ms 23888 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 10 ms 23888 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 10 ms 23888 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -