Submission #1070794

# Submission time Handle Problem Language Result Execution time Memory
1070794 2024-08-22T18:37:07 Z MohamedFaresNebili Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
    #include <bits/stdc++.h>
    #include "closing.h"
     
            using namespace std;
     
            vector<pair<int, long long>> adj[200005];
            long long D[200005][2];
            vector<long long> pL, pR, pM;
            void dfs(int X, int p, int st) {
                for(auto u : adj[X]) {
                    if(u.first == p) continue;
                    D[u.first][st] = D[X][st] + u.second;
                    dfs(u.first, X, st);
                }
            }
            int sum(int l, int r, vector<int> arr) {
                return arr[r] - (l > 0 ? arr[l - 1] : 0);
            }
     
            int max_score(int N, int X, int Y, long long K,
                vector<int> U, vector<int> V, vector<int> W) {
                pL.resize(N); pR.resize(N); pM.resize(N);
                for(int l = 0; l < N; l++) D[l][0] = D[l][1] = 2e18 + 7, adj[l].clear();
                for(int l = 0; l < N - 1; l++) {
                    adj[U[l]].push_back({V[l], W[l]});
                    adj[V[l]].push_back({U[l], W[l]});
                }
                if(X > Y) swap(X, Y);
                D[X][0] = 0, D[Y][1] = 0;
                dfs(X, X, 0); dfs(Y, Y, 1);
                for(int l = 0; l < N; l++) {
                    pL[l] = D[l][0];
                    pR[l] = D[l][1];
                    pM[l] = min(D[l][0], D[l][1]);
                    if(l > 0) {
                        pL[l] += pL[l - 1];
                        pR[l] += pR[l - 1];
                        pM[l] += pM[l - 1];
                    }
                }
                int res = 0;
                for(int l = X; l >= 0; l--) {
                    for(int i = X; i < N; i++) {
                        for(int j = Y; j >= 0; j--) {
                            for(int e = Y; e < N; e++) {
                                int lo = max(l, j), hi = min(i, e);
                                long long calc = 0;
                                if(lo > hi) {
                                    calc += sum(l, i, pL);
                                    calc += sum(j, e, pR);
                                }
                                else {
                                    calc += sum(l, i, pL);
                                    calc += sum(j, e, pR);
                                    calc -= sum(lo, hi, pM);
                                }
                                if(calc <= K) res = max(res,  i - l + e - j + 2);
                            }
                        }
                    }
                }
                return res;
            }

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:49:55: error: could not convert 'pL' from 'vector<long long int>' to 'vector<int>'
   49 |                                     calc += sum(l, i, pL);
      |                                                       ^~
      |                                                       |
      |                                                       vector<long long int>
closing.cpp:50:55: error: could not convert 'pR' from 'vector<long long int>' to 'vector<int>'
   50 |                                     calc += sum(j, e, pR);
      |                                                       ^~
      |                                                       |
      |                                                       vector<long long int>
closing.cpp:53:55: error: could not convert 'pL' from 'vector<long long int>' to 'vector<int>'
   53 |                                     calc += sum(l, i, pL);
      |                                                       ^~
      |                                                       |
      |                                                       vector<long long int>
closing.cpp:54:55: error: could not convert 'pR' from 'vector<long long int>' to 'vector<int>'
   54 |                                     calc += sum(j, e, pR);
      |                                                       ^~
      |                                                       |
      |                                                       vector<long long int>
closing.cpp:55:57: error: could not convert 'pM' from 'vector<long long int>' to 'vector<int>'
   55 |                                     calc -= sum(lo, hi, pM);
      |                                                         ^~
      |                                                         |
      |                                                         vector<long long int>