Submission #411600

# Submission time Handle Problem Language Result Execution time Memory
411600 2021-05-25T14:57:56 Z MDario Dreaming (IOI13_dreaming) C++11
18 / 100
61 ms 16616 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb(x) push_back(x)
const ll mod=1e9+7;
ll r=0, c1, c2, c3;
vector<pair<ll, ll>> v[100001];
vector<ll> v1;
pair<ll, ll> a1, a2, p[100001];
bool b[100001];
pair<ll, ll> dfs(ll xf, ll axf){
    b[xf]=1;
    pair<ll, ll> a3={xf, 0}, a4;
    for(auto i : v[xf]){
        if(i.F!=axf){
            p[i.F]={xf, i.S};
            a4=dfs(i.F, xf);
            if(a4.S+i.S>a3.S){
                a3={a4.F, a4.S+i.S};
            }
        }
    }
    return a3;
}
int travelTime(int n, int m, int l, int A[], int B[], int T[]) {
    for(int i=0; i<m; i++){
        c1=A[i];
        c2=B[i];
        c3=T[i];
        v[c1].push_back({c2, c3});
        v[c2].push_back({c1, c3});
    }
    for(int i=1; i<=n; i++){
        if(!b[i]){
            a1=dfs(i, i);
            a2=dfs(a1.F, a1.F);
            c1=a2.S;
            c2=0;
            c3=c1;
            r=max(r, a2.S);
            while(a2.F!=a1.F){
                c1-=p[a2.F].S;
                c2+=p[a2.F].S;
                c3=min(c3, max(c1, c2));
                a2.F=p[a2.F].F;
            }
            v1.push_back(c3);
        }
    }
    if(v1.size()==1)return r;
    sort(v1.begin(), v1.end());
    reverse(v1.begin(), v1.end());
    r=max(r, v1[0]+v1[1]+l);
    for(int i=2; i<v1.size(); i++){
        r=max(r, v1[0]+v1[i]+l);
        r=max(r, v1[1]+v1[i]+l+l);
    }
    return r;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=2; i<v1.size(); i++){
      |                  ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 61 ms 16568 KB Output is correct
2 Correct 58 ms 16616 KB Output is correct
3 Correct 36 ms 11712 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 8 ms 3916 KB Output is correct
6 Correct 15 ms 5836 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2564 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 16568 KB Output is correct
2 Correct 58 ms 16616 KB Output is correct
3 Correct 36 ms 11712 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 8 ms 3916 KB Output is correct
6 Correct 15 ms 5836 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 7152 KB Output is correct
2 Correct 27 ms 7116 KB Output is correct
3 Correct 26 ms 7132 KB Output is correct
4 Correct 25 ms 7112 KB Output is correct
5 Correct 36 ms 7084 KB Output is correct
6 Correct 29 ms 7840 KB Output is correct
7 Correct 27 ms 7300 KB Output is correct
8 Correct 32 ms 7080 KB Output is correct
9 Correct 25 ms 7092 KB Output is correct
10 Correct 28 ms 7300 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 8 ms 4956 KB Output is correct
13 Correct 7 ms 5316 KB Output is correct
14 Correct 7 ms 4932 KB Output is correct
15 Correct 7 ms 5060 KB Output is correct
16 Correct 7 ms 4804 KB Output is correct
17 Correct 7 ms 4164 KB Output is correct
18 Correct 8 ms 5444 KB Output is correct
19 Correct 8 ms 4804 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2764 KB Output is correct
23 Correct 7 ms 4876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2564 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 16568 KB Output is correct
2 Correct 58 ms 16616 KB Output is correct
3 Correct 36 ms 11712 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 8 ms 3916 KB Output is correct
6 Correct 15 ms 5836 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -