Submission #81472

# Submission time Handle Problem Language Result Execution time Memory
81472 2018-10-24T20:34:12 Z farukkastamonuda Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000009
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
int x=-inf,xx=-inf,xxx=-inf,vis[li],mn,M[li],M2[li],node[li],ss,m;
vector< pair<int,int> > v[li];
void f(int x){
	vis[x]=1;
	int t;
	for(int i=0;i<(int)v[x].size();i++){
		int go=v[x][i].fi;
		int knr=v[x][i].se;
		if(vis[go]==1) continue;
		f(go);
		t=M[go]+knr;
		if(M[x]<t){
			M2[x]=M[x];
			M[x]=t;
			node[x]=go;
		}
		else if(M2[x]<t){
			M2[x]=t;
		}
	}
	ss=max(ss,M[x]+M2[x]);
}
void g(int x,int p,int t){
	mn=min(mn,max(M[x],t));
	for(int i=0;i<(int)v[x].size();i++){
		int go=v[x][i].fi;
		int knr=v[x][i].se;
		if(go==p) continue;
		int a=max(t,node[x]==go?M2[x]:M[x]);
		g(go,x,a+knr);
	}
}
int travelTime(int n,int m,int l,int *A,int *B,int *T){
	for(int i=0;i<m;i++){
		v[A[i]].pb(mp(B[i],T[i]));
		v[B[i]].pb(mp(A[i],T[i]));
	}
	x=-inf,xx=-inf,xxx=-inf
	for(int i=0;i<n;i++){
		if(vis[i]==1) continue;
		mn=inf;
		f(i);
		g(i,-1,0);
		if(x<mn){
			x=mn;
			xx=x;
			xxx=xx;
		}
		else if(xx<mn){
			xx=mn;
			xxx=xx;
		}
		else if(xxx<mn){
			xxx=mn;
		}
	}
	return max(ss,max(x+xx+l,xx+xxx+l+l));
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:50:2: error: expected ';' before 'for'
  for(int i=0;i<n;i++){
  ^~~
dreaming.cpp:50:14: error: 'i' was not declared in this scope
  for(int i=0;i<n;i++){
              ^