답안 #29599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29599 2017-07-20T08:09:50 Z aybala 꿈 (IOI13_dreaming) C++11
컴파일 오류
0 ms 0 KB
#include "dreaming.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(int a=b; a<c; a++)
#define ford(a,b,c) for(int a=b; a>=c; a++)
#define pb push_back
#define pq priority_queue
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
vector< pii >v[100004];
vector< int >el[2];

int vis[100004];
int sp[100004];
int lp[2];
int dis[100004];
int deep[100004];
int g[100004];
int dp[2];
int reans[2];

int dfs(int u, int pre, int gr){
	int s=v[u].size();
	vis[u]=1;
	el[gr].pb(u);
	int res;
	fori(i,0,s){
		if(pre!=v[u][i].fi){
			res=dfs(v[u][i].fi,u,g);
			dis[u]+=dis[v[u][i].fi]+v[u][i].se;
			
		}
	}
	deep[u]=deep[pre]+1;
	g[u]=gr;
	res=max(res,dis[u]);
	dp[gr]=max(dp[gr],deep[u]-1);
	return res;
}

/*void dfs2(int u, int pre,int gr){
	int s=v[u].size();
	int loc[100004];
	
	fori(i,0,dp[gr]){
		if()
	}
	
	fori(i,0,s){
		if(pre!=v[u][i].fi){
			dfs2(v[u][i],u);
		}
	}
}*/

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n=N;
	fori(i,0,M){
		v[A[i]].pb(mp(B[i],T[i]));
		v[B[i]].pb(mp(A[i],T[i]));
	}
	
	int gr=0;
	fori(i,0,n){
		if(v[i].size()==1 && !vis[i]){
			int k = dfs(i,i,gr);
			int els=el[gr].size();
			int ans=dis[el[gr][els-1]];
			int reans[gr]=i;
			fori(j,1,s){
				int loc[100004];
				int locmax=0;
				fori(l,0,s){
					if(l==j){
						loc[l]=0;
					}
					if(l>j){
						loc[l]=dis[el[gr][l]]-dis[el[gr][j]];
					}
					if(l<j){
						loc[l]=dis[el[gr][j]]-dis[el[gr][l]];
					}
					locmax=max(locmax,loc[l]);
				}
				ans=min(locmax,ans);
				reans[gr]=el[gr][j];
				lp[gr]=ans;
			}
			gr++;
		}
	}
	
	
		int els=el[gr].size();
		gr=i;
		int j=reans[gr];
				int loc[100004];
				int locmax=L;
				fori(l,0,s){
					if(l==j){
						loc[l]=0;
					}
					if(l>j){
						loc[l]=dis[el[gr][l]]-dis[el[gr][j]];
					}
					if(l<j){
						loc[l]=dis[el[gr][j]]-dis[el[gr][l]];
					}
					locmax=max(locmax,loc[l]+L+lp[gr]);
				}
				

	return locmax;
	
}

Compilation message

dreaming.cpp: In function 'int dfs(int, int, int)':
dreaming.cpp:31:26: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    res=dfs(v[u][i].fi,u,g);
                          ^
dreaming.cpp:24:5: note:   initializing argument 3 of 'int dfs(int, int, int)'
 int dfs(int u, int pre, int gr){
     ^~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:59:2: error: 'n' was not declared in this scope
  n=N;
  ^
dreaming.cpp:71:18: error: array must be initialized with a brace-enclosed initializer
    int reans[gr]=i;
                  ^
dreaming.cpp:72:13: error: 's' was not declared in this scope
    fori(j,1,s){
             ^
dreaming.cpp:3:36: note: in definition of macro 'fori'
 #define fori(a,b,c) for(int a=b; a<c; a++)
                                    ^
dreaming.cpp:68:8: warning: unused variable 'k' [-Wunused-variable]
    int k = dfs(i,i,gr);
        ^
dreaming.cpp:97:6: error: 'i' was not declared in this scope
   gr=i;
      ^
dreaming.cpp:101:14: error: 's' was not declared in this scope
     fori(l,0,s){
              ^
dreaming.cpp:3:36: note: in definition of macro 'fori'
 #define fori(a,b,c) for(int a=b; a<c; a++)
                                    ^
dreaming.cpp:96:7: warning: unused variable 'els' [-Wunused-variable]
   int els=el[gr].size();
       ^~~