Submission #415069

# Submission time Handle Problem Language Result Execution time Memory
415069 2021-05-31T13:39:26 Z Emin2004 Dreaming (IOI13_dreaming) C++14
18 / 100
81 ms 11788 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second

const int N = 100005;

int used[N];
int dis[N];
vector <pii> v[N];

void DFS(int node){
    used[node] = 1;
    dis[node] = 0;
    for(pii i : v[node]){
        if(!used[i.F]){
            used[i.F] = 1;
            DFS(i.F);
            dis[node] += i.S + dis[i.F];
        }
    }
}

int getans(int node, int sum){
    used[node] = 0;
    int res = sum - dis[node];
    for(pii i : v[node]){
        if(used[i.F]){
            res = max(res, dis[i.F] + i.S);
        }
    }
    for(pii i : v[node]){
        if(used[i.F]){
            used[i.F] = 0;
            res = min(res, getans(i.F, sum));
        }
    }
    return res;
}

int travelTime(int n, int m, int l, int a[], int b[], int t[]) {
   // return n;
    if(n == 1) return 0;
    for(int i = 0; i < m; i++){
        v[a[i]].pb({b[i], t[i]});
        v[b[i]].pb({a[i], t[i]});
    }
    for(int i = 0; i < n; i++){
        if(!used[i]) {
            DFS(i);
        }
    }
    vector<int> results;
    for(int i = 0; i < n; i++){
        if(used[i] != 0){
            int cur = getans(i, dis[i]);
            results.pb(cur);
        }
    }
    sort(results.begin(), results.end());
    int sz = results.size();
    int ans = results[sz - 1] + results[sz - 2] + l;
    if(sz >= 3) ans = max(ans, results[sz - 2] + results[sz - 3] + l + l);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 11788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 11788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 6448 KB Output is correct
2 Correct 37 ms 6452 KB Output is correct
3 Correct 30 ms 6488 KB Output is correct
4 Correct 35 ms 6468 KB Output is correct
5 Correct 24 ms 6412 KB Output is correct
6 Correct 36 ms 6984 KB Output is correct
7 Correct 29 ms 6600 KB Output is correct
8 Correct 36 ms 6368 KB Output is correct
9 Correct 24 ms 6396 KB Output is correct
10 Correct 25 ms 6604 KB Output is correct
11 Correct 4 ms 2636 KB Output is correct
12 Correct 7 ms 4040 KB Output is correct
13 Correct 6 ms 4072 KB Output is correct
14 Correct 6 ms 4040 KB Output is correct
15 Correct 6 ms 4056 KB Output is correct
16 Correct 7 ms 4060 KB Output is correct
17 Correct 6 ms 4040 KB Output is correct
18 Correct 7 ms 4040 KB Output is correct
19 Correct 7 ms 3992 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 3 ms 2636 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 7 ms 4028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 11788 KB Output isn't correct
2 Halted 0 ms 0 KB -