Submission #1079129

# Submission time Handle Problem Language Result Execution time Memory
1079129 2024-08-28T11:02:37 Z beaconmc Closing Time (IOI23_closing) C++17
0 / 100
59 ms 10044 KB
#include "closing.h"
#include <bits/stdc++.h>
    
using namespace std; 
 
 
typedef long long ll;
    
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 

ll n;

vector<vector<ll>> edges[3005];
ll dist1[3005];
ll dist2[3005];
ll dp[3005][6005];
vector<vector<ll>> dists;


void dfs(ll a, ll p, ll d, ll type){
    if (type==1) dist1[a] = d;
    else dist2[a] = d;

    for (auto&i : edges[a]){
        if (i[0] != p) dfs(i[0], a, d+i[1], type);
    }
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    n = N;
    FOR(i,0,N+1) edges[i].clear();
    FOR(i,0,N-1){
        edges[U[i]].push_back({V[i], W[i]});
        edges[V[i]].push_back({U[i], W[i]});
    }
    dfs(X, -1, 0, 1);
    dfs(Y, -1, 0, 2);



    FOR(i,0,N){
        vector<ll> temp = {};
        temp.push_back(min(dist1[i], dist2[i]));
        temp.push_back(dist1[i] + dist2[i]);
        dists.push_back(temp);
    }

    FOR(i,0,N) FOR(j,0,2*N+1) dp[i][j] = 100000000000000000;
    
    dp[0][0] = 0;
    dp[0][1] = dists[0][0];
    dp[0][2] = dists[0][1];


    FOR(i,1,N){
        FOR(j,0,2*N+1){
            ll temp = 100000000000000000;
            if (j>=1) temp = min(temp, dp[i-1][j-1]+dists[i][0]);
            if (j>=2) temp = min(temp, dp[i-1][j-2]+dists[i][1]);
            temp = min(temp, dp[i-1][j]);
            dp[i][j] = temp;
        }
    }
    ll ans = 0;

    FOR(i,0,N){
        FOR(j,0,2*N+1){
            if (dp[i][j] <=K){

                ans = max(ans, j);
            }

        }
    }
    return ans;




}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 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 Runtime error 59 ms 10044 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 2396 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 0 ms 348 KB Output is correct
2 Incorrect 1 ms 2396 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 0 ms 348 KB Output is correct
2 Incorrect 1 ms 2396 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 1 ms 2396 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 1 ms 2396 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 1 ms 2396 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 1 ms 2396 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 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -