Submission #1070599

# Submission time Handle Problem Language Result Execution time Memory
1070599 2024-08-22T15:46:20 Z HorizonWest Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 41960 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define fs first 
#define sd second 

const ll Inf = 1e18 + 7;

vector <ll> bfs(int n, int x, vector <vector<pair<ll, ll>>> v)
{
    vector <ll> D(n + 1, Inf), P(n + 1);
    queue <int> q; q.push(x); P[x] = 1; 

    while (!q.empty())
    {
        int x = q.front(); q.pop();

        for(auto& u : v[x]) if(!P[u.fs])
        {   
            P[u.fs] = 1; D[u.fs] = D[x] + u.sd; 
            q.push(u.fs);
        }
    }
    
    return D;
}

int max_score(int n, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
{
    vector <vector<pair<ll, ll>>> v(n + 1,  vector <pair<ll, ll>> ());

    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] });
    }

    vector <ll> d1 = bfs(n, X, v), d2 = bfs(n, Y, v);

    vector <ll> dp(2 * n + 1, Inf);

    for(int i = 0; i < n; i++)
    {
        for(int j = 2*n; j >= 0; j--)
        {
            if(j > 0) dp[j] = min(dp[j], dp[j-1] + d1[i]);
            if(j > 0) dp[j] = min(dp[j], dp[j-1] + d2[i]);
            if(j > 1) dp[j] = min(dp[j], dp[j-2] + max(d1[i], d2[i]));
        }
    }

    int ans = 0; 

    for(int i = 0; i <= 2*n; i++) 
    {
        if(dp[i] <= K)
        {
            ans = i;
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 41960 KB Time limit exceeded
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: '3', found: '0'
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: '3', found: '0'
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: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -