답안 #913309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
913309 2024-01-20T07:20:15 Z abcvuitunggio 봉쇄 시간 (IOI23_closing) C++17
35 / 100
164 ms 29640 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
vector <pair <int, int>> ke[200001];
long long d[200001][2],cur;
int p[200001],ch[200001];
priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> q;
void dfs(int u, int par, int i){
    for (auto [v,w]:ke[u])
        if (v!=par){
            d[v][i]=d[u][i]+w;
            p[v]=u;
            dfs(v,u,i);
        }
}
int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W){
    for (int i=0;i<N-1;i++){
        ke[U[i]].push_back({V[i],W[i]});
        ke[V[i]].push_back({U[i],W[i]});
    }
    memset(ch,0,sizeof(ch));
    d[X][0]=d[Y][1]=0;
    dfs(X,X,0);
    dfs(Y,Y,1);
    for (;X!=Y;X=p[X])
        ch[X]=1;
    ch[Y]=1;
    int res=0,cnt=0;
    long long dist=0;
    for (int i=0;i<N;i++){
        q.push({min(d[i][0],d[i][1]),i});
        if (ch[i])
            dist+=min(d[i][0],d[i][1]);
    }
    cur=0;
    while (!q.empty()&&cur+q.top().first<=K){
        cur+=q.top().first;
        res++;
        q.pop();
    }
    while (!q.empty())
        q.pop();
    if (dist<=K){
        for (int i=0;i<N;i++){
            if (ch[i])
                q.push({abs(d[i][0]-d[i][1]),i});
            else
                q.push({min(d[i][0],d[i][1]),i});
            cnt+=ch[i];
        }
        cur=dist;
        while (!q.empty()&&cur+q.top().first<=K){
            cur+=q.top().first;
            int u=q.top().second;
            cnt++;
            q.pop();
            if (!ch[u]){
                q.push({abs(d[u][0]-d[u][1]),u});
                ch[u]=1;
            }
        }
        while (!q.empty())
            q.pop();
    }
    for (int i=0;i<N;i++)
        ke[i].clear();
    return max(res,cnt);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 29640 KB 1st lines differ - on the 1st token, expected: '451', found: '200000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7924 KB Output is correct
2 Correct 3 ms 7772 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7768 KB Output is correct
6 Correct 3 ms 7772 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7768 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7768 KB Output is correct
11 Correct 4 ms 7768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7924 KB Output is correct
2 Correct 3 ms 7772 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7768 KB Output is correct
6 Correct 3 ms 7772 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7768 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7768 KB Output is correct
11 Correct 4 ms 7768 KB Output is correct
12 Correct 3 ms 7936 KB Output is correct
13 Correct 3 ms 7768 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 3 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 4 ms 7608 KB Output is correct
19 Correct 4 ms 7924 KB Output is correct
20 Correct 3 ms 7928 KB Output is correct
21 Correct 4 ms 7772 KB Output is correct
22 Correct 4 ms 7604 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 3 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7924 KB Output is correct
2 Correct 3 ms 7772 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7768 KB Output is correct
6 Correct 3 ms 7772 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7768 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7768 KB Output is correct
11 Correct 4 ms 7768 KB Output is correct
12 Correct 3 ms 7936 KB Output is correct
13 Correct 3 ms 7768 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 3 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 4 ms 7608 KB Output is correct
19 Correct 4 ms 7924 KB Output is correct
20 Correct 3 ms 7928 KB Output is correct
21 Correct 4 ms 7772 KB Output is correct
22 Correct 4 ms 7604 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 3 ms 7772 KB Output is correct
25 Correct 6 ms 7768 KB Output is correct
26 Correct 5 ms 8024 KB Output is correct
27 Correct 4 ms 8028 KB Output is correct
28 Correct 6 ms 8200 KB Output is correct
29 Correct 4 ms 8028 KB Output is correct
30 Correct 6 ms 8028 KB Output is correct
31 Correct 5 ms 8028 KB Output is correct
32 Correct 4 ms 8028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
2 Correct 4 ms 7924 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7772 KB Output is correct
6 Correct 3 ms 7768 KB Output is correct
7 Incorrect 4 ms 7776 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
2 Correct 4 ms 7924 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7772 KB Output is correct
6 Correct 3 ms 7768 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 3 ms 7768 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7768 KB Output is correct
12 Correct 4 ms 7768 KB Output is correct
13 Correct 3 ms 7936 KB Output is correct
14 Correct 3 ms 7768 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 3 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Incorrect 4 ms 7776 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
2 Correct 4 ms 7924 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7772 KB Output is correct
6 Correct 3 ms 7768 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 3 ms 7768 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7768 KB Output is correct
12 Correct 4 ms 7768 KB Output is correct
13 Correct 3 ms 7936 KB Output is correct
14 Correct 3 ms 7768 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 3 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 4 ms 7608 KB Output is correct
20 Correct 4 ms 7924 KB Output is correct
21 Correct 3 ms 7928 KB Output is correct
22 Correct 4 ms 7772 KB Output is correct
23 Correct 4 ms 7604 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 3 ms 7772 KB Output is correct
26 Incorrect 4 ms 7776 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
2 Correct 4 ms 7924 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7772 KB Output is correct
6 Correct 3 ms 7768 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 3 ms 7768 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7768 KB Output is correct
12 Correct 4 ms 7768 KB Output is correct
13 Correct 3 ms 7936 KB Output is correct
14 Correct 3 ms 7768 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 3 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 4 ms 7608 KB Output is correct
20 Correct 4 ms 7924 KB Output is correct
21 Correct 3 ms 7928 KB Output is correct
22 Correct 4 ms 7772 KB Output is correct
23 Correct 4 ms 7604 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 3 ms 7772 KB Output is correct
26 Correct 6 ms 7768 KB Output is correct
27 Correct 5 ms 8024 KB Output is correct
28 Correct 4 ms 8028 KB Output is correct
29 Correct 6 ms 8200 KB Output is correct
30 Correct 4 ms 8028 KB Output is correct
31 Correct 6 ms 8028 KB Output is correct
32 Correct 5 ms 8028 KB Output is correct
33 Correct 4 ms 8028 KB Output is correct
34 Incorrect 4 ms 7776 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7772 KB Output is correct
2 Correct 4 ms 7924 KB Output is correct
3 Correct 3 ms 7772 KB Output is correct
4 Correct 3 ms 7772 KB Output is correct
5 Correct 3 ms 7772 KB Output is correct
6 Correct 3 ms 7768 KB Output is correct
7 Correct 3 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 3 ms 7768 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7768 KB Output is correct
12 Correct 4 ms 7768 KB Output is correct
13 Correct 3 ms 7936 KB Output is correct
14 Correct 3 ms 7768 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 3 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 4 ms 7608 KB Output is correct
20 Correct 4 ms 7924 KB Output is correct
21 Correct 3 ms 7928 KB Output is correct
22 Correct 4 ms 7772 KB Output is correct
23 Correct 4 ms 7604 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 3 ms 7772 KB Output is correct
26 Correct 6 ms 7768 KB Output is correct
27 Correct 5 ms 8024 KB Output is correct
28 Correct 4 ms 8028 KB Output is correct
29 Correct 6 ms 8200 KB Output is correct
30 Correct 4 ms 8028 KB Output is correct
31 Correct 6 ms 8028 KB Output is correct
32 Correct 5 ms 8028 KB Output is correct
33 Correct 4 ms 8028 KB Output is correct
34 Incorrect 4 ms 7776 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
35 Halted 0 ms 0 KB -