답안 #1078166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078166 2024-08-27T13:28:21 Z mindiyak 식물 비교 (IOI20_plants) C++14
0 / 100
1 ms 600 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)) return 1;
	}
	a = pos[y];
	if(m[R[a].F] == 1){
		if(R[a].S == (N-y+x)) return 1;
	}

	a = pos[x];
	if(m[R[a].F] == 1){
		if(R[a].S == (y-x)) return -1;
	}
	a = pos[y];
	if(m[R[a].F] == 0){
		if(R[a].S == (N-y+x)) 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++){
      |              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -