답안 #768986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768986 2023-06-29T04:02:18 Z ono_de206 식물 비교 (IOI20_plants) C++14
컴파일 오류
0 ms 0 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

vector<int> a, pre;
int n;

void init(int _k, vector<int> r) {
	k = _k;
	n = r.size();
	pre.resize(n * 3);
	for(int i = 0; i < 3; i++) {
		a.in(a.end(), all(r));
	}
	pre[0] = a[0];
	for(int i = 0; i + 1 < n * 3; i++) {
		pre[i + 1] = pre[i] + a[i + 1];
	}
}

int compare_plants(int x, int y) {
	if(x < y) {
		int sum = pre[y - 1] - (x == 0 ? 0 : pre[x - 1]);
		if(sum == y - x) return -1;
		sum = pre[x + n - 1] - pre[y - 1];
		if(sum == x + n - y) return 1;
	} else {
		int sum = pre[y + n - 1] - pre[x - 1];
		if(sum == y + n - x) return -1;
		sum = pre[x - 1] - (y == 0 ? 0 : pre[y - 1]);
		if(sum == x - y) return 1;
	}
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:25:2: error: 'k' was not declared in this scope; did you mean '_k'?
   25 |  k = _k;
      |  ^
      |  _k