답안 #1074236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074236 2024-08-25T08:58:45 Z Trumling 꿈 (IOI13_dreaming) C++14
14 / 100
51 ms 14956 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

vector<vector<pair<ll,ll>>>g;
vector<bool>vis;
ll n,m;
void dfs1(int start,ll &count)
{
    for(auto x:g[start])
        if(!vis[x.F])
        {
            vis[x.F]=1;
            count+=x.S;
            dfs1(x.F, count);
        }
}

void dfs2(int start,int pre,ll &ans,ll diff,ll curr,ll count)
{
    if(diff > abs((count-curr)-curr))
            {
                ans=max(curr,count-curr);
                diff= abs((count-curr)-curr);
            }

    for(auto x:g[start])
        if(x.F!=pre)
            dfs2(x.F,start,ans,diff,curr + x.S,count);
        
}   
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n=N;
    m=M;

    g.assign(n,vector<pair<ll,ll>>());
    vis.assign(n,0);

    for(int i=0;i<m;i++)
        {
            g[A[i]].pb({B[i],T[i]});
            g[B[i]].pb({A[i],T[i]});
        }
    
    vector<ll>ans(2,0);
    ll ansi=0;
    ll idx=0;
    for(int i=0;i<N;i++)
        if(!vis[i] && g[i].size()==1)
        {
            vis[i]=1;
            ll count=0;
            dfs1(i,count);
            ansi=max(ansi,count);

            dfs2(i,i,ans[idx++],INF,0,count);
        }
    


    return max(ansi,ans[0] + ans[1] + L);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 14956 KB Output is correct
2 Correct 32 ms 14956 KB Output is correct
3 Correct 24 ms 9920 KB Output is correct
4 Correct 8 ms 2396 KB Output is correct
5 Correct 4 ms 1628 KB Output is correct
6 Correct 9 ms 3676 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 5976 KB Output is correct
9 Correct 34 ms 7988 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 31 ms 10132 KB Output is correct
12 Correct 51 ms 12660 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 14956 KB Output is correct
2 Correct 32 ms 14956 KB Output is correct
3 Correct 24 ms 9920 KB Output is correct
4 Correct 8 ms 2396 KB Output is correct
5 Correct 4 ms 1628 KB Output is correct
6 Correct 9 ms 3676 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 5976 KB Output is correct
9 Correct 34 ms 7988 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 31 ms 10132 KB Output is correct
12 Correct 51 ms 12660 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 9812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 14956 KB Output is correct
2 Correct 32 ms 14956 KB Output is correct
3 Correct 24 ms 9920 KB Output is correct
4 Correct 8 ms 2396 KB Output is correct
5 Correct 4 ms 1628 KB Output is correct
6 Correct 9 ms 3676 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 5976 KB Output is correct
9 Correct 34 ms 7988 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 31 ms 10132 KB Output is correct
12 Correct 51 ms 12660 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -