답안 #196850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
196850 2020-01-17T09:13:15 Z awlintqaa 꿈 (IOI13_dreaming) C++14
18 / 100
335 ms 28784 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
#define C continue
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pi> vpi;
#include "dreaming.h"
ll n,m,k;
vpll v[100009];
map<pll,ll>mp;
ll done[100009];
vll ret,all;
ll mx,id,z;
void dfs1(int node,int p,ll crnt){
        done[node]=1;
        if(crnt>=mx){
                mx=crnt;
                id=node;
        }
        for(auto u:v[node]){
                if(u.fi==p)C;
                dfs1(u.fi,node,crnt+u.se);
        }
}
void dfs2(int node,int p){
        done[node]=1;
        if(!z)ret.pb(node);
        if(node==id){
                z=1;
                return ;
        }
        for(auto u:v[node]){
                if(u.fi==p)C;
                dfs2(u.fi,node);
                if(z)return ;
        }
        if(!z)ret.ppb();
}
int find(){
        vll X;
        X.resize((int)ret.size());
        ll crnt=0;
        for(int i=0;i<ret.size();i++){
                if(i)crnt+=mp[{ret[i],ret[i-1]}];
                X[i]=max(X[i],crnt);
        }
        crnt=0;
        ll timer=ret.size()-1;
        for(int i=0;i<ret.size();i++){
                if(i)crnt+=mp[{ret[i],ret[i-1]}];
                X[timer]=max(X[timer],crnt);
                timer--;
        }
        ll mn=1e9*2;
        for(int i=0;i<X.size();i++){
                mn=min(mn,X[i]);
        }
        return mn;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
        n=N,m=M,k=L;
        for(int i=0;i<m;i++){
                int a=A[i],b=B[i],c=T[i];
                v[a].pb({b,c});
                v[b].pb({a,c});
                mp[{a,b}]=mp[{b,a}]=c;
        }
        for(int i=0;i<n;i++){
                if(done[i])C;
                mx=id=-1;
                z=0;
                ret.clear();
                dfs1(i,i,0);
                int xxx=id;
                mx=id=-1;
                dfs1(xxx,xxx,0);
                dfs2(xxx,xxx);
                all.pb(find());
        }
        sort(all.begin(),all.end());
        reverse(all.begin(),all.end());
        ll mx=0;
        if(all.size()==1)mx=all[0];
        if(all.size()==2)mx=all[0]+all[1]+L;
        if(all.size()>2){
                mx=all[0]+all[1]+L;
                mx=max(mx,all[1]+all[2]+L+L);
        }
        return mx;
}

Compilation message

dreaming.cpp: In function 'int find()':
dreaming.cpp:51:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<ret.size();i++){
                     ~^~~~~~~~~~~
dreaming.cpp:57:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<ret.size();i++){
                     ~^~~~~~~~~~~
dreaming.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<X.size();i++){
                     ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 10688 KB Output is correct
2 Correct 93 ms 10764 KB Output is correct
3 Correct 93 ms 10696 KB Output is correct
4 Correct 91 ms 10740 KB Output is correct
5 Correct 88 ms 10740 KB Output is correct
6 Correct 92 ms 11760 KB Output is correct
7 Correct 88 ms 11228 KB Output is correct
8 Correct 82 ms 10616 KB Output is correct
9 Correct 85 ms 10608 KB Output is correct
10 Correct 93 ms 11000 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 15 ms 4720 KB Output is correct
13 Correct 15 ms 4724 KB Output is correct
14 Correct 14 ms 4592 KB Output is correct
15 Correct 14 ms 4724 KB Output is correct
16 Correct 15 ms 4592 KB Output is correct
17 Correct 16 ms 4464 KB Output is correct
18 Correct 18 ms 4720 KB Output is correct
19 Correct 16 ms 4592 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 14 ms 4592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -