Submission #843669

# Submission time Handle Problem Language Result Execution time Memory
843669 2023-09-04T11:38:16 Z Boas Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 45952 KB
#include "closing.h"
using namespace std;
#include <bits/stdc++.h>
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef vector<sii> vsii;
typedef tuple<ll, ll, ll, bool> item;

#define ALL(x) (x).begin(), x.end()
#define loop(x, i) for (int i = 0; i < x; i++)

void getDist(int i, ll d, vi &dist, const vsii &adj)
{
    dist[i] = d;
    for (auto [j, w] : adj[i])
    {
        if (dist[j] != -1)
            continue;
        getDist(j, dist[i] + w, dist, adj);
    }
}

int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
{
    vsii adj(N);
    loop(N - 1, i)
    {
        adj[U[i]].insert({V[i], W[i]});
        adj[V[i]].insert({U[i], W[i]});
    }
    vi distX(N, -1), distY(N, -1);
    distX[X] = 0;
    distY[Y] = 0;
    getDist(X, 0, distX, adj);
    getDist(Y, 0, distY, adj);
    int res = 0;
    vb visX(N);
    vb visY(N);
    for (int xleft = X; xleft >= 0; xleft--)
    {
        for (int xright = X; xright < N; xright++)
        {
            for (int yleft = Y; yleft >= 0; yleft--)
            {
                for (int yright = Y; yright < N; yright++)
                {
                    ll sum;
                    for (int p = 0; p < N; p++)
                    {
                        ll v = 0;
                        if (xleft <= p && p <= xright)
                            v = max(v, distX[p]);
                        if (yleft <= p && p <= yright)
                            v = max(v, distY[p]);
                        sum += v;
                    }
                    if (sum <= K)
                    {
                        res = max(res, 2 + yright + xright - xleft - yleft);
                    }
                }
            }
        }
    }
    cerr << endl;
    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:61:29: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |                         sum += v;
      |                         ~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 45952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '9'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '9'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '9'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -