Submission #60988

# Submission time Handle Problem Language Result Execution time Memory
60988 2018-07-25T05:20:48 Z WA_TLE Dreaming (IOI13_dreaming) C++14
0 / 100
103 ms 12796 KB
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<pair<int,int>>go[100000];
bool used[100000]={};
int ans=0;
tuple<int,int,int>cho;
int man=mod;
int ski[100000];
#include"dreaming.h"
pair<int,int> dfs(int ter,int per){
	used[ter]=1;
	pair<int,int> gen=mp(0,ter);
	for(int z=0;z<go[ter].size();z++){
		auto it=go[ter][z];
		int y=it.sec;
		if(y==per){continue;}
		auto ret=dfs(y,ter);
		ret.fir+=it.fir;
		if(gen<ret){swap(gen,ret);}
		maxeq(cho,mt(gen.fir+ret.fir,gen.sec,ret.sec));
	}
	return gen;
}
//一番遠い距離,その場所を持つ
void ddfs(int ter,int per,int dis,bool fla){
	if(fla){mineq(man,max(ski[ter],dis));}
	else{ski[ter]=dis;}
	for(int z=0;z<go[ter].size();z++){
		auto it=go[ter][z];
		int y=it.sec;
		if(y==per){continue;}
		ddfs(y,ter,dis+it.sec,fla);
	}
}
int travelTime(int N,int M,int L,int A[],int B[],int T[]){
	int i,j;
	for(i=0;i<M;i++){
		go[A[i]].pub(mp(T[i],B[i]));
		go[B[i]].pub(mp(T[i],A[i]));
	}
	int tos[4]={0};
	for(i=0;i<N;i++){
		if(used[i]){continue;}
		auto ret=dfs(i,-1);
		maxeq(ans,get<0>(cho));
		man=mod;
		ddfs(get<1>(cho),-1,0,0);
		ddfs(get<2>(cho),-1,0,1);
		tos[3]=man;
		for(j=3;j>0;j--){
			if(tos[j]>tos[j-1]){swap(tos[j],tos[j-1]);}else{break;}
		}
	}
	maxeq(ans,tos[0]+tos[1]+L);
	maxeq(ans,tos[1]+tos[2]+L);
	return ans;
}

Compilation message

dreaming.cpp: In function 'std::pair<int, int> dfs(int, int)':
dreaming.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int z=0;z<go[ter].size();z++){
              ~^~~~~~~~~~~~~~~
dreaming.cpp: In function 'void ddfs(int, int, int, bool)':
dreaming.cpp:77:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int z=0;z<go[ter].size();z++){
              ~^~~~~~~~~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:93:8: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
   auto ret=dfs(i,-1);
        ^~~
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12792 KB Output is correct
2 Correct 76 ms 12796 KB Output is correct
3 Incorrect 50 ms 9592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12792 KB Output is correct
2 Correct 76 ms 12796 KB Output is correct
3 Incorrect 50 ms 9592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12792 KB Output is correct
2 Correct 76 ms 12796 KB Output is correct
3 Incorrect 50 ms 9592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 5192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12792 KB Output is correct
2 Correct 76 ms 12796 KB Output is correct
3 Incorrect 50 ms 9592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12792 KB Output is correct
2 Correct 76 ms 12796 KB Output is correct
3 Incorrect 50 ms 9592 KB Output isn't correct
4 Halted 0 ms 0 KB -