Submission #795102

# Submission time Handle Problem Language Result Execution time Memory
795102 2023-07-27T06:36:04 Z Khizri Dreaming (IOI13_dreaming) C++17
0 / 100
29 ms 13396 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
const int mxn=1e5+5;
int n,m,color[mxn],mx,node,node2,res;
vector<pii>vt[mxn];
vector<int>a,b;
pii back[mxn];
void dfs(int u,int p,ll dis){
    a.pb(dis);
    color[u]=1;
    for(pii v:vt[u]){
        if(v.F!=p){
            dfs(v.F,u,v.S);
        }
    }
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n=N,m=M;
    for(int i=0;i<m;i++){
        vt[A[i]+1].pb({B[i]+1,T[i]});
        vt[B[i]+1].pb({A[i]+1,T[i]});
    }
    for(int i=1;i<=n;i++){
        color[i]=0;
    }
    vector<int>vtt;
    for(int i=1;i<=n;i++){
        if(color[i]) continue;
        mx=0,node=0;
        if(vt[i].size()<2){
            b=a;
            a.clear();
            dfs(i,-1,0);
        }
    }
    ll x=0,y=0;
    for(int v:a){
        x+=v;
    }
    for(int v:b){
        y+=v;
    }
    ll l=x,r=y;
    ll sum=0;
    for(int i=0;i<a.size();i++){
        sum+=a[i];
        x-=a[i];
        l=min(l,max(sum,x));
    }
    sum=0;
    for(int i=0;i<b.size();i++){
        sum+=b[i];
        y-=b[i];
        r=min(r,max(sum,y));
    }
    //cout<<l<<' '<<r<<endl;
    return l+r+L;
    sort(rall(vtt));
    if(vtt.size()==1) return vtt[0];
    int ans=vtt[0]+vtt[1]+L;
    if(vtt.size()>2){
        ans=max(ans,vtt[1]+vtt[2]+2*L);
    }
    return ans;
}
/*
12 8 2
0 8 4
8 2 2 
2 7 4
5 11 3
5 1 7
1 3 1
1 9 5
10 6 3
 
6 5 3
0 1 2
1 2 1
2 3 2
3 4 1
4 5 0
*/

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
dreaming.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=0;i<b.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 13396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 13396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 5352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 13396 KB Output isn't correct
2 Halted 0 ms 0 KB -