답안 #1008192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008192 2024-06-26T08:19:03 Z 12345678 봉쇄 시간 (IOI23_closing) C++17
21 / 100
1000 ms 31412 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)
{
    if (X>Y) swap(X, Y);
    for (int i=0; i<N; i++) d[i].clear();
    for (int i=0; i<N-1; 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++) cout<<a[i]<<' '<<b[i]<<'\n';
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i=0; i<N; i++) pq.push(a[i]), pq.push(b[i]);
    ll tmp=K;
    while (!pq.empty()&&pq.top()<=tmp) mx++, tmp-=pq.top(), pq.pop();
    for (int i=0; i<N; i++)
    {
        for (int j=i; j<N; j++)
        {
            ll c=K, res=2*(j-i+1);
            for (int k=i; k<=j; k++) c-=max(a[k], b[k]);
            for (int k=X; k<i; k++) res++, c-=a[k];
            for (int k=j+1; k<=Y; k++) res++, c-=b[k];
            if (c<0) continue;
            while (!pq.empty()) pq.pop();
            for (int k=0; k<min(X, i); k++) pq.push(a[k]);
            for (int k=max(Y, j)+1; k<N; k++) pq.push(b[k]);
            while (!pq.empty()&&c>=pq.top()) c-=pq.top(), pq.pop(), res++;
            mx=max(mx, res);
        }
    }
    return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 31412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 5132 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 5132 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 4 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 2 ms 5220 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 715 ms 5136 KB Output is correct
20 Correct 23 ms 5200 KB Output is correct
21 Correct 312 ms 4956 KB Output is correct
22 Correct 23 ms 4956 KB Output is correct
23 Correct 32 ms 4952 KB Output is correct
24 Correct 32 ms 5204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 5132 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 4 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 2 ms 5220 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 715 ms 5136 KB Output is correct
20 Correct 23 ms 5200 KB Output is correct
21 Correct 312 ms 4956 KB Output is correct
22 Correct 23 ms 4956 KB Output is correct
23 Correct 32 ms 4952 KB Output is correct
24 Correct 32 ms 5204 KB Output is correct
25 Correct 19 ms 5212 KB Output is correct
26 Execution timed out 1054 ms 5468 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -