Submission #966384

# Submission time Handle Problem Language Result Execution time Memory
966384 2024-04-19T19:05:23 Z VMaksimoski008 Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

int n, x, y;
ll k;
vector<vector<pair<int, int> >> graph;
const int maxn = 2e5 + 5;
using ll = long long;
ll dist[2][maxn];

void dfs(int u, int p, int t) {
    for(auto &[v, w] : graph[u]) {
        if(v == p) continue;
        dist[t][v] = dist[t][u] + w;
        dfs(v, u, t);
    }
}

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;
    x = X;
    y = Y;
    k = K;
    graph.resize(n);

    bool line = 1;
    for(int i=0; i<n-1; i++) {
        if(abs(U[i] - V[i]) != 1) line = 0;
        graph[U[i]].push_back({ V[i], W[i] });
        graph[V[i]].push_back({ U[i], W[i] });
    }

    if(line) {
        int ans = 0;
        dfs(x, x, 0);
        dfs(y, y, 1);

        for(int a=x; a<n; a++) {
            for(int b=x; b>=0; b--) {
                for(int c=y; c<n; c++) {
                    for(int d=y; d>=0; d--) {
                        ll total = 0;
                        for(int i=0; i<n; i++) {
                            ll curr = 0;
                            if(b <= i && i <= a) curr = max(curr, dist[0][i]);
                            if(d <= i && i <= c) curr = max(curr, dist[1][i]);
                            total += curr;
                        }

                        if(total <= k) ans = max(ans, a - b + c - d);
                    }
                }
            }
        }

        return ans + 2;
    }

    int ans = 0;
    ll total = k;
    dfs(x, x, 0);
    dfs(y, y, 1);
    
    vector<ll> v;
    for(int i=0; i<2; i++)
        for(int j=0; j<n; j++) v.push_back(dist[i][j]);
    sort(v.begin(), v.end());

    for(auto &x : v) {
        if(x > total) break;
        ans++;
        total -= x;
    }

    return ans;
}

Compilation message

closing.cpp:6:1: error: 'll' does not name a type
    6 | ll k;
      | ^~
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:24:5: error: 'k' was not declared in this scope
   24 |     k = K;
      |     ^