Submission #94154

# Submission time Handle Problem Language Result Execution time Memory
94154 2019-01-16T11:56:22 Z fjzzq2002 Dreaming (IOI13_dreaming) C++14
32 / 100
49 ms 11512 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef pair<int,int> pii;
#define fi first
#define se second
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int ff[SZ]; Edgc
int gf(int x) {return (~ff[x])?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{
	a=gf(a),b=gf(b);
	if(a==b) throw "GG";
	ff[a]=b;
}
int ca=0;
pii mx;
int fa[SZ],fe[SZ];
void dfs(int x,int d=0)
{
	mx=max(mx,pii(d,x));
	for esb(x,e,b) if(b!=fa[x])
		fa[b]=x,fe[b]=vc[e],dfs(b,d+vc[e]);
}
int work(int t)
{
	mx=pii(-1,0);
	fa[t]=-1; dfs(t);
	ca=max(ca,mx.fi);
	int u=mx.se;
	mx=pii(-1,0);
	fa[u]=-1; dfs(u);
	int su=0,aa=mx.fi; t=mx.se;
	while(u!=t)
	{
		su+=fe[t],t=fa[t];
		aa=min(aa,max(su,mx.fi-su));
	}
	return aa;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    ca=0;
	memset(ff,-1,sizeof ff);
    for(int i=0;i<M;++i)
    	adde(A[i],B[i],T[i]),uni(A[i],B[i]);
    vector<int> v;
    for(int i=0;i<N;++i)
    	if(gf(i)==i) v.pb(work(i));
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=1;i<v.size();++i) v[i]+=L;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    if(v.size()>=2) ca=max(ca,v[0]+v[1]);
	return ca;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:54:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<v.size();++i) v[i]+=L;
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11512 KB Output is correct
2 Correct 47 ms 11512 KB Output is correct
3 Correct 31 ms 8568 KB Output is correct
4 Correct 9 ms 4224 KB Output is correct
5 Correct 8 ms 3712 KB Output is correct
6 Correct 14 ms 4864 KB Output is correct
7 Correct 4 ms 2944 KB Output is correct
8 Correct 24 ms 6144 KB Output is correct
9 Correct 30 ms 7296 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 42 ms 8552 KB Output is correct
12 Correct 49 ms 9976 KB Output is correct
13 Correct 4 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11512 KB Output is correct
2 Correct 47 ms 11512 KB Output is correct
3 Correct 31 ms 8568 KB Output is correct
4 Correct 9 ms 4224 KB Output is correct
5 Correct 8 ms 3712 KB Output is correct
6 Correct 14 ms 4864 KB Output is correct
7 Correct 4 ms 2944 KB Output is correct
8 Correct 24 ms 6144 KB Output is correct
9 Correct 30 ms 7296 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 42 ms 8552 KB Output is correct
12 Correct 49 ms 9976 KB Output is correct
13 Correct 4 ms 3072 KB Output is correct
14 Incorrect 4 ms 3072 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11512 KB Output is correct
2 Correct 47 ms 11512 KB Output is correct
3 Correct 31 ms 8568 KB Output is correct
4 Correct 9 ms 4224 KB Output is correct
5 Correct 8 ms 3712 KB Output is correct
6 Correct 14 ms 4864 KB Output is correct
7 Correct 4 ms 2944 KB Output is correct
8 Correct 24 ms 6144 KB Output is correct
9 Correct 30 ms 7296 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 42 ms 8552 KB Output is correct
12 Correct 49 ms 9976 KB Output is correct
13 Correct 4 ms 3072 KB Output is correct
14 Incorrect 4 ms 3072 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 5624 KB Output is correct
2 Correct 20 ms 5572 KB Output is correct
3 Correct 21 ms 5632 KB Output is correct
4 Correct 20 ms 5624 KB Output is correct
5 Correct 21 ms 5624 KB Output is correct
6 Correct 21 ms 6012 KB Output is correct
7 Correct 21 ms 5632 KB Output is correct
8 Correct 19 ms 5624 KB Output is correct
9 Correct 20 ms 5504 KB Output is correct
10 Correct 20 ms 5632 KB Output is correct
11 Correct 4 ms 2944 KB Output is correct
12 Correct 9 ms 4860 KB Output is correct
13 Correct 9 ms 4860 KB Output is correct
14 Correct 9 ms 4732 KB Output is correct
15 Correct 9 ms 4732 KB Output is correct
16 Correct 9 ms 4732 KB Output is correct
17 Correct 9 ms 4348 KB Output is correct
18 Correct 9 ms 4860 KB Output is correct
19 Correct 9 ms 4732 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 4 ms 2944 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 9 ms 4732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11512 KB Output is correct
2 Correct 47 ms 11512 KB Output is correct
3 Correct 31 ms 8568 KB Output is correct
4 Correct 9 ms 4224 KB Output is correct
5 Correct 8 ms 3712 KB Output is correct
6 Correct 14 ms 4864 KB Output is correct
7 Correct 4 ms 2944 KB Output is correct
8 Correct 24 ms 6144 KB Output is correct
9 Correct 30 ms 7296 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 42 ms 8552 KB Output is correct
12 Correct 49 ms 9976 KB Output is correct
13 Correct 4 ms 3072 KB Output is correct
14 Incorrect 4 ms 3072 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11512 KB Output is correct
2 Correct 47 ms 11512 KB Output is correct
3 Correct 31 ms 8568 KB Output is correct
4 Correct 9 ms 4224 KB Output is correct
5 Correct 8 ms 3712 KB Output is correct
6 Correct 14 ms 4864 KB Output is correct
7 Correct 4 ms 2944 KB Output is correct
8 Correct 24 ms 6144 KB Output is correct
9 Correct 30 ms 7296 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 42 ms 8552 KB Output is correct
12 Correct 49 ms 9976 KB Output is correct
13 Correct 4 ms 3072 KB Output is correct
14 Incorrect 4 ms 3072 KB Output isn't correct
15 Halted 0 ms 0 KB -