Submission #768996

# Submission time Handle Problem Language Result Execution time Memory
768996 2023-06-29T04:31:15 Z ono_de206 Comparing Plants (IOI20_plants) C++14
Compilation error
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, dp1, dp2;
int n, k;

void init(int _k, vector<int> r) {
	k = _k;
	n = r.size();
	pre.resize(n * 3);
	dp1.resize(n * 3);
	dp2.resize(n * 3);
	for(int i = 0; i < 3; i++) {
		a.in(a.end(), all(r));
	}
	int ls1 = -1, ls2= -1;
	for(int i = n * 3 - 1; i >= 0; i--) {
		if(a[i] == 0) {
			if(ls1 != -1 && ls1 - i < k) dp1[i] = dp1[ls];
			else dp1[i] = i;
		} else if(a[i] == k - 1) {
			if(ls2 != -1 && ls2 - i < k) dp2[i] = dp2[ls];
			else dp2[i] = i;
		}
	}
}

int compare_plants(int x, int y) {
	if(x < y) {
		if(a[x] == 0 && dp1[x] + k - 1 >= y) return 1;
		if(a[x] == k - 1 && dp2[x] + k - 1 >= y) return -1;
		if(a[y] == 0 && dp1[y] + k - 1 >= x + n) return -1;
		if(a[y] == k - 1 && dp2[y] + k - 1 >= x + n) return 1;
	} else {
		if(a[x] == 0 && dp1[x] + k - 1 >= y + n) return 1;
		if(a[x] == k - 1 && dp2[x] + k - 1 >= y + n) return -1;
		if(a[y] == 0 && dp1[y] + k - 1 >= x) return -1;
		if(a[y] == k - 1 && dp2[y] + k - 1 >= x) return 1;
	}
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:36:46: error: 'ls' was not declared in this scope; did you mean 'ls2'?
   36 |    if(ls1 != -1 && ls1 - i < k) dp1[i] = dp1[ls];
      |                                              ^~
      |                                              ls2
plants.cpp:39:46: error: 'ls' was not declared in this scope; did you mean 'ls2'?
   39 |    if(ls2 != -1 && ls2 - i < k) dp2[i] = dp2[ls];
      |                                              ^~
      |                                              ls2