답안 #814694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
814694 2023-08-08T09:02:48 Z vjudge1 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
#include "plants.h"
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
int n, K;
vi cmp;
void init(int k, vector<int> r) {
	n = (int)r.size();
	K = k;
	cmp = r;
}

int compare_plants(int x, int y) {
	if(K == 2){
		if(abs(x-y) > 1)
			return 0;
		if(x > y){
			if(cmp[y] == 1)	return -1;
			else return 1;
		}
		else{
			if(cmp[x] == 1)	return -1;
			else return 1;
		}
	}
}

Compilation message

plants.cpp:12:5: error: redefinition of 'int n'
   12 | int n, K;
      |     ^
In file included from plants.cpp:3:
grader.cpp:9:12: note: 'int n' previously declared here
    9 | static int n, k, q;
      |            ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^