Submission #1078150

# Submission time Handle Problem Language Result Execution time Memory
1078150 2024-08-27T13:22:29 Z mindiyak Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 348 KB
#include "plants.h"
#include <iostream>
using namespace std;

#define F first
#define S second

vector<pair<int,int>> R;
vector<int> pos;
vector<int> m;
int N;

void init(int k, std::vector<int> r) {
	int start = 0;
	int len = 1;
	pos.push_back(R.size());
	N = r.size();
	for(int l=1;l<r.size()*2;l++){
		int i = l%r.size();
		if(r[i] == r[start]){
			len ++;
		}else{
			R.push_back({start,len});
			start = i;
			len = 1;
		}
		pos.push_back(R.size());
	}
	m = r;
	return;
}

int compare_plants(int x, int y) {
	int a=x;
	// cerr << x << " " << y << endl;

	a = pos[x];
	if(m[R[a].F] == 0){
		if(R[a].S > (y-x-1)) return 1;
	}
	a = pos[y];
	if(m[R[a].F] == 1){
		if(R[a].S > (N-y+x-1)) return 1;
	}

	a = pos[x];
	if(m[R[a].F] == 1){
		if(R[a].S > (y-x-1)) return -1;
	}
	a = pos[y];
	if(m[R[a].F] == 0){
		if(R[a].S > (N-y+x-1)) return -1;
	}
	
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int l=1;l<r.size()*2;l++){
      |              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -