Submission #914203

# Submission time Handle Problem Language Result Execution time Memory
914203 2024-01-21T10:50:49 Z Ludissey Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 165836 KB
#include <bits/stdc++.h>
#include "closing.h"

using namespace std;
#define int long long
const int INF=1e9;
vector<vector<pair<int,int>>> edges;
vector<int> dstX;
vector<int> dstY;
map<pair<int,int>,int> mp;
int n;
int dp(int i, int res){
    if(res<0) return -INF;
    if(i>=n) return 0;
    if(mp.find({i,res})!=mp.end()) return mp[{i,res}];
    int next=dp(i+1, res);
    int cl1=dp(i+1, res-min(dstY[i],dstX[i]))+1;
    int cl2=dp(i+1, res-dstY[i]-dstX[i])+2;
    return mp[{i,res}]=max(max(cl1, cl2), next);
}
signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){
    edges.clear();
    mp.clear();
    dstX.clear();
    edges.resize(N);
    dstX.resize(N);
    dstY.resize(N);
    n=N;
    for (int i = 0; i < N-1; i++)
    {
        edges[V[i]].push_back({U[i], W[i]});
        edges[U[i]].push_back({V[i], W[i]});
    }
    vector<bool> visited(N);
    queue<pair<int,int>> queue;
    queue.push({rootX,0});
    while(!queue.empty()){
        int x=queue.front().first,w=queue.front().second; queue.pop();
        if(visited[x]) continue;
        visited[x]=true;
        dstX[x]=w;
        for (auto u: edges[x]) queue.push({u.first, u.second+w});
    }
    visited.clear();
    visited.resize(N);
    queue.push({rootY,0});
    while(!queue.empty()){
        int x=queue.front().first,w=queue.front().second; queue.pop();
        if(visited[x]) continue;
        visited[x]=true;
        dstY[x]=w;
        for (auto u: edges[x]) queue.push({u.first, u.second+w});
    }
    return (int)dp(0,K);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 Execution timed out 1037 ms 165836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 684 KB Output is correct
2 Execution timed out 1045 ms 77080 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 684 KB Output is correct
2 Execution timed out 1045 ms 77080 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 684 KB Output is correct
2 Execution timed out 1045 ms 77080 KB Time limit exceeded
3 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: '5'
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: '5'
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: '5'
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: '5'
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: '5'
2 Halted 0 ms 0 KB -