Submission #1007970

# Submission time Handle Problem Language Result Execution time Memory
1007970 2024-06-26T03:56:32 Z 12345678 Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 25664 KB
#include "closing.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=2e5+5;

vector<pair<ll, ll>> d[nx];

void dfs(int u, int p, ll cw, vector<ll> &x)
{
    x[u]=cw;
    for (auto [v, w]:d[u]) if (v!=p) dfs(v, u, cw+w, x);
}

int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    for (int i=0; i<N; i++) d[i].clear();
    for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], W[i]}), d[V[i]].push_back({U[i], W[i]});
    vector<ll> a(N), b(N);
    ll mx=0;
    dfs(X, X, 0, a);
    dfs(Y, Y, 0, b);
    for (int i=0; i<N; i++)
    {
        for (int j=i; j<N; j++)
        {
            ll t=0, c=K, res=2*(j-i+1);
            for (int k=i; k<=j; k++) t+=max(a[k], b[k]);
            if (t>c) continue;
            priority_queue<ll, vector<ll>, greater<ll>> pq;
            c-=t;
            for (int k=0; k<i; k++) pq.push(a[k]), pq.push(b[k]);
            for (int k=j+1; k<N; k++) pq.push(a[k]), pq.push(b[k]);
            while (!pq.empty()&&pq.top()<=c) c-=pq.top(), res++, pq.pop();
            mx=max(mx, res);
        }
    }
    return mx;
}

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:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], W[i]}), d[V[i]].push_back({U[i], W[i]});
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 25664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -