Submission #843671

# Submission time Handle Problem Language Result Execution time Memory
843671 2023-09-04T11:39:43 Z Boas Closing Time (IOI23_closing) C++17
9 / 100
1000 ms 45800 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 = 0;
                    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;
}
# 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 1086 ms 45800 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 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 52 ms 412 KB Output is correct
7 Correct 40 ms 348 KB Output is correct
8 Correct 15 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 52 ms 412 KB Output is correct
7 Correct 40 ms 348 KB Output is correct
8 Correct 15 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 186 ms 440 KB Output is correct
13 Correct 111 ms 348 KB Output is correct
14 Correct 392 ms 424 KB Output is correct
15 Correct 161 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 14 ms 444 KB Output is correct
19 Execution timed out 1027 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 52 ms 412 KB Output is correct
7 Correct 40 ms 348 KB Output is correct
8 Correct 15 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 186 ms 440 KB Output is correct
13 Correct 111 ms 348 KB Output is correct
14 Correct 392 ms 424 KB Output is correct
15 Correct 161 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 14 ms 444 KB Output is correct
19 Execution timed out 1027 ms 344 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 -