Submission #915346

# Submission time Handle Problem Language Result Execution time Memory
915346 2024-01-23T18:06:57 Z Ludissey Closing Time (IOI23_closing) C++17
9 / 100
1000 ms 31572 KB
#include <bits/stdc++.h>
#include "closing.h"

using namespace std;
#define int long long
#define sz(a){ return (int)a.size(); }

const int INF=1e9;
vector<vector<pair<int,int>>> edges;
vector<int> dstX;
vector<int> dstY;

signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){
    vector<pair<int,int>> singl;
    vector<pair<int,int>> doubl;
    edges.clear();
    dstX.clear();
    edges.resize(N);
    dstX.resize(N);
    dstY.resize(N);
    singl.resize(N);
    doubl.resize(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]});
    }
    if(rootX>rootY) swap(rootX, rootY);
    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});
    } 
    int mx=0;
    for (int l1 = rootX; l1 >= 0; l1--)
    {
        for (int r1 = rootX; r1 < N; r1++)
        {
            for (int l2 = rootY; l2 >= 0; l2--)
            {
                for (int r2 = rootY; r2 < N; r2++)
                {
                    int sum=0;
                    for (int i = 0; i < N; i++)
                    {
                        if(l1<=i&&r1>=i&&l2<=i&&r2>=i) sum+=max(dstX[i],dstY[i]);
                        else if(l1<=i&&r1>=i) sum+=dstX[i];
                        else if(l2<=i&&r2>=i) sum+=dstY[i];
                    }
                    if(sum>K) continue;
                    //cerr << l1 << " " << r1 << " " << l2 << " " << r2 << "\n";
                    mx=max((r1-l1)+(r2-l2)+2,mx);
                }
            }
        }
    }
    
    
    return (int)mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 1046 ms 31572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 43 ms 344 KB Output is correct
7 Correct 32 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 3 ms 560 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 43 ms 344 KB Output is correct
7 Correct 32 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 3 ms 560 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 138 ms 348 KB Output is correct
13 Correct 87 ms 348 KB Output is correct
14 Correct 315 ms 420 KB Output is correct
15 Correct 122 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 432 KB Output is correct
18 Correct 11 ms 348 KB Output is correct
19 Execution timed out 1065 ms 348 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 43 ms 344 KB Output is correct
7 Correct 32 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 3 ms 560 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 138 ms 348 KB Output is correct
13 Correct 87 ms 348 KB Output is correct
14 Correct 315 ms 420 KB Output is correct
15 Correct 122 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 432 KB Output is correct
18 Correct 11 ms 348 KB Output is correct
19 Execution timed out 1065 ms 348 KB Time limit exceeded
20 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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
2 Halted 0 ms 0 KB -