답안 #7433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7433 2014-08-05T08:42:19 Z gs13068 철로 (IOI14_rail) C++
컴파일 오류
0 ms 0 KB
#include "rail.h"
#include <algorithm>

std::pair<int,int> sta[5000];

void findLocation(int n,int fir,int loc[],int type[])
{
  int l,r;
  int ld,rd;
  int i,j,k;
  loc[0]=fir;
  type[0]=1;
  for(i=1;i<n;i++)
  {
    sta[i].first=getDistance(0,i);
    sta[i].second=i;
  }
  std::sort(sta,sta+n);
  loc[sta[1].second]=fir+sta[1].first;
  type[sta[1].second]=2;
  l=0;
  r=sta[1].second;
  for(i=2;i<n;i++)
  {
    ld=getDistance(l,sta[i].second);
    rd=getDistance(r,sta[i].second);
    k=-1;
    for(j=0;j<i;j++)if(type[sta[j].second]==2&&loc[sta[j].second]>loc[0]&&(k<0||loc[sta[j].second<loc[sta[k].second]))k=j;
    if(k<0||loc[sta[k].second]-loc[0]+loc[sta[k].second]-(loc[r]-rd)!=sta[k].first)
    {
      loc[sta[i].second]=loc[l]+ld;
      type[sta[i].second]=2;
    }
    else
    {
      k=-1;
      for(j=0;j<i;j++)if(type[sta[j].second]==2&&loc[sta[j].second]>loc[l]&&(k<0||loc[sta[j].second<loc[sta[k].second]))k=j;
      if(k<0||loc[sta[k].second]-loc[l]+loc[sta[k].second]-(loc[r]-rd)!=ld)
      {
        loc[sta[i].second]=loc[l]+ld;
        type[sta[i].second]=2;
      }
      else
      {
        loc[sta[i].second]=loc[r]-rd;
        type[sta[i].second]=1;
      }
    }
  }
}

Compilation message

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:28:117: error: expected ']' before ')' token
     for(j=0;j<i;j++)if(type[sta[j].second]==2&&loc[sta[j].second]>loc[0]&&(k<0||loc[sta[j].second<loc[sta[k].second]))k=j;
                                                                                                                     ^
rail.cpp:37:119: error: expected ']' before ')' token
       for(j=0;j<i;j++)if(type[sta[j].second]==2&&loc[sta[j].second]>loc[l]&&(k<0||loc[sta[j].second<loc[sta[k].second]))k=j;
                                                                                                                       ^