답안 #29044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29044 2017-07-18T07:28:11 Z aybala 코끼리 (Dancing Elephants) (IOI11_elephants) C++11
컴파일 오류
0 ms 0 KB
#include "elephants.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(a=b; a<c; a++)
#define ford(a,b,c) for(a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int n;

int cam;

int a[2];

void init(int N, int L, int X[])
{
	int i,j,k;
	int l = X[0];
	a[0]=X[0];
	a[1]=X[1];
	cam = 1;
	fori(i,1,N){
		if(X[i]-l>L){
			l=X[i];
			cam++;
		}
	}
	
}

int update(int i, int y)
{
	if(i==2){
		a[0]=a[1]=y;
		return cam;
	}
	
	if(i==1){
		if(abs(a[1]-y)>abs(a[0]-y)){
			a[1]=y;
		}
		else{
			a[0]=y;
		}
		int l = a[0];
		cam = 1;
		fori(i,1,N){
			if(a[i]-l>L){
				l=a[i];
				cam++;
			}
		}	
	}
	
	return cam;
}

Compilation message

elephants.cpp: In function 'void init(int, int, int*)':
elephants.cpp:18:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,k;
        ^
elephants.cpp:18:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k;
          ^
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:48:12: error: 'N' was not declared in this scope
   fori(i,1,N){
            ^
elephants.cpp:3:32: note: in definition of macro 'fori'
 #define fori(a,b,c) for(a=b; a<c; a++)
                                ^
elephants.cpp:49:14: error: 'L' was not declared in this scope
    if(a[i]-l>L){
              ^