Submission #693296

# Submission time Handle Problem Language Result Execution time Memory
693296 2023-02-02T15:47:26 Z PoonYaPat Dreaming (IOI13_dreaming) C++14
0 / 100
35 ms 10964 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int mmax[100001],dis_min,mmax1,mmax2,mnode;
bool vis[100001];
vector<pii> adj[100001];
vector<int> v;

void dfs1(int x, int par, int root) {
    vis[x]=true;
    for (auto s : adj[x]) {
        if (s.first==par) continue;
        dfs1(s.first,x,root);
        int dis=mmax[s.first]+s.second;

        if (x==root) {

            if (mmax1<=dis) {
                mmax2=mmax1;
                mmax1=dis;
                mnode=s.first;
            } else if (mmax2<=dis) mmax2=dis;

        } else mmax[x]=max(mmax[x],dis);
    }
}

void dfs2(int x, int par, int dis) {
    dis_min=min(dis_min,max(mmax[x],dis));
    for (auto s : adj[x]) if (s.first!=par) dfs2(s.first,x,dis+s.second);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for (int i=0; i<M; ++i) {
        adj[A[i]].push_back(pii(B[i],T[i]));
        adj[B[i]].push_back(pii(A[i],T[i]));
    }
    for (int i=0; i<N; ++i) {
        if (!vis[i]) {
            mmax1=mmax2=0;
            dfs1(i,-1,i);
            dis_min=mmax1;
            for (auto s : adj[i]) {
                if (s.first==mnode) dfs2(mnode,i,mmax2+s.second);
            }
            v.push_back(dis_min);
        }
    }

    sort(v.begin(),v.end(),greater<int>());
    if (v.size()==2) return v[0]+v[1]+L;
    return max(v[0]+v[1]+L,v[1]+v[2]+2*L);
}
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 10964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 10964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 5356 KB Output is correct
2 Correct 16 ms 5460 KB Output is correct
3 Correct 17 ms 5424 KB Output is correct
4 Correct 18 ms 5460 KB Output is correct
5 Correct 20 ms 5456 KB Output is correct
6 Correct 17 ms 5848 KB Output is correct
7 Correct 17 ms 5488 KB Output is correct
8 Correct 16 ms 5336 KB Output is correct
9 Correct 15 ms 5332 KB Output is correct
10 Correct 16 ms 5452 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 4 ms 3408 KB Output is correct
13 Correct 6 ms 3408 KB Output is correct
14 Correct 4 ms 3408 KB Output is correct
15 Correct 4 ms 3408 KB Output is correct
16 Correct 4 ms 3408 KB Output is correct
17 Correct 5 ms 3408 KB Output is correct
18 Correct 4 ms 3408 KB Output is correct
19 Correct 4 ms 3408 KB Output is correct
20 Incorrect 1 ms 2644 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 10964 KB Output isn't correct
2 Halted 0 ms 0 KB -