Submission #415750

# Submission time Handle Problem Language Result Execution time Memory
415750 2021-06-01T12:58:46 Z Emin2004 Dreaming (IOI13_dreaming) C++14
18 / 100
100 ms 13772 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][2];
vector <pii> v[N];
vector <int> vis;

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

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]});
    }
    vector<int> results;
    for(int i = 0; i < n; i++){
        if(!used[i]) {
            DFS(i,0);
            int mx = 0, dd;
            for(int j : vis){
                used[j] = 0;
                if(dis[j][0] >= mx) {
                    mx = dis[j][0];
                    dd = j;
                }
                dis[j][0] = 0;
            }
            vis.clear();
            DFS(dd, 0);
            mx = 0;
            for(int j : vis){
                used[j] = 0;
                if(dis[j][0] >= mx) {
                    mx = dis[j][0];
                    dd = j;
                }
            }
            vis.clear();
            DFS(dd, 1);
            for(int j : vis){
                mx = min(mx, max(dis[j][0], dis[j][1]));
                dis[j][0] = 0;
                dis[j][1] = 0;
            }
            vis.clear();
            results.pb(mx);
           // return mx;
        }
    }
    sort(results.begin(), results.end());
    int sz = results.size();
    int ans = results[sz - 1];
    if(sz >= 2) ans += results[sz - 2] + l;
    if(sz >= 3) ans = max(ans, results[sz - 2] + results[sz - 3] + l + l);
    return ans;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:51:16: warning: 'dd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |             DFS(dd, 0);
      |             ~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 13772 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 100 ms 13772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 6396 KB Output is correct
2 Correct 50 ms 6392 KB Output is correct
3 Correct 61 ms 6812 KB Output is correct
4 Correct 44 ms 6784 KB Output is correct
5 Correct 44 ms 6844 KB Output is correct
6 Correct 46 ms 7328 KB Output is correct
7 Correct 44 ms 7004 KB Output is correct
8 Correct 28 ms 6728 KB Output is correct
9 Correct 26 ms 6764 KB Output is correct
10 Correct 43 ms 6996 KB Output is correct
11 Correct 4 ms 2636 KB Output is correct
12 Correct 9 ms 4448 KB Output is correct
13 Correct 8 ms 4424 KB Output is correct
14 Correct 11 ms 4320 KB Output is correct
15 Correct 8 ms 4444 KB Output is correct
16 Correct 19 ms 4312 KB Output is correct
17 Correct 9 ms 4292 KB Output is correct
18 Correct 9 ms 4424 KB Output is correct
19 Correct 9 ms 4424 KB Output is correct
20 Correct 3 ms 2636 KB Output is correct
21 Correct 3 ms 2656 KB Output is correct
22 Correct 4 ms 2636 KB Output is correct
23 Correct 9 ms 4424 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 100 ms 13772 KB Output isn't correct
2 Halted 0 ms 0 KB -