답안 #1015694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015694 2024-07-06T16:39:45 Z XJP12 식물 비교 (IOI20_plants) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
vi v;
vi sum;
int n;
void init(int k, vi r){
	n = r.size();
	//cout<<n<<endl;
	sum.resize(n,0);
	for(int i=0; i<n; i++){
		v.push_back(r[i]);
		sum[i]+=v[i];
		if(i>0) sum[i]+=sum[i-1];
		//cout<<sum[i]<<" ";
	}
//	cout<<endl;
}
int compare_plants(int x, int y){
	ll ans1=0, ans2=0;
	ans1=sum[y-1];
	//cout<<ans1<<ans2<<endl;
	if(x>0) ans1-=sum[x-1];
	ans2=sum[n-1]-ans1;
	//cout<<ans1<<ans2<<endl;
	if(ans1==y-x || ans2==0){
		return -1;
	}
	if(ans1==0 || ans2==n-y+x){
		return 1;
	}
	return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccV3PmZI.o: in function `main':
grader.cpp:(.text.startup+0x2fb): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status