답안 #590557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590557 2022-07-06T06:35:46 Z mohammad_kilani 꿈 (IOI13_dreaming) C++17
10 / 100
1000 ms 9984 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;

vector< vector< pair< int , int > > > adj;

bool DFS(int node,int parent,int destination){
    if(node == destination)
        return true;
    for(int i = 0 ;i < (int)adj[node].size();i++){
        if(adj[node][i].first == parent)
            continue;
        if(DFS(adj[node][i].first,  node, destination))
            return true;
    }
    return false;
}

int maximum_distance , best_node;

void DFS2(int node,int parent,int distance){
    if(distance > maximum_distance){
        maximum_distance = distance;
        best_node = node;
    }
    for(int i = 0 ;i < (int)adj[node].size();i++){
        if(adj[node][i].first != parent)
            DFS2(adj[node][i].first , node , distance + adj[node][i].second);
    }
}

int FindLongestPath(){
    maximum_distance = -1;
    DFS2(0 , -1 , 0);
    maximum_distance = -1;
    DFS2(best_node , -1 , 0);
    return maximum_distance;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    adj.resize(N);
    for(int i = 0 ;i < M;i++){
        adj[A[i]].push_back(make_pair(B[i] , T[i]));
        adj[B[i]].push_back(make_pair(A[i] , T[i]));
    }
    int ans = (int)1e9;
    for(int i = 0 ;i < N;i++){
        for(int j = i + 1;j < N;j++){
            if(DFS(i , -1 , j))
                continue;
            adj[i].push_back(make_pair(j , L));
            adj[j].push_back(make_pair(i , L));
            //cout << i << " " << j << " " << L << " : " << FindLongestPath() << endl;
            ans = min(ans , FindLongestPath());
            adj[i].pop_back();
            adj[j].pop_back();
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 9984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 316 KB Output is correct
2 Correct 9 ms 340 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 6 ms 324 KB Output is correct
5 Correct 7 ms 304 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 320 KB Output is correct
13 Correct 6 ms 324 KB Output is correct
14 Correct 5 ms 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 304 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 5 ms 308 KB Output is correct
21 Correct 6 ms 304 KB Output is correct
22 Correct 6 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 5 ms 304 KB Output is correct
25 Correct 5 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 9984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 6220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 316 KB Output is correct
2 Correct 9 ms 340 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 6 ms 324 KB Output is correct
5 Correct 7 ms 304 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 320 KB Output is correct
13 Correct 6 ms 324 KB Output is correct
14 Correct 5 ms 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 304 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 5 ms 308 KB Output is correct
21 Correct 6 ms 304 KB Output is correct
22 Correct 6 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 5 ms 304 KB Output is correct
25 Correct 5 ms 212 KB Output is correct
26 Incorrect 62 ms 468 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 9984 KB Time limit exceeded
2 Halted 0 ms 0 KB -