답안 #823971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823971 2023-08-13T10:52:39 Z thimote75 식물 비교 (IOI20_plants) C++14
14 / 100
4000 ms 6720 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;

void shift (idata &r, int count) {
	idata h;
	for (int i = count; i < r.size(); i ++)
		h.push_back(r[i]);
	for (int i = 0; i < count; i ++)
		h.push_back(r[i]);
	
	r.swap(h);
}

idata A;

void init(int k, idata r) {
	int n = r.size();

	A.resize(n);

	int s = 0;

	for (int v = n - 1; v >= 0; v --) {
		int p = 0; int m = 1e9;

		for (int i = 0; i < n; i ++) {
			if (r[i] > m) continue ;
			if (r[i] == m) {
				int d = n + p - i;
				if (d >= k) continue ;
			}
		
			p = i;
			m = r[i];
		}

		r[p] = 1e9;
		for (int g = p - 1; g > p - k; g --) r[(g + n) % n] --;
	
		A[p] = v;
	}

	return;
}

int compare_plants(int x, int y) {
	int del = A[x] - A[y];
	if (del == 0) return 0;
	return del / abs(del);
}

Compilation message

plants.cpp: In function 'void shift(idata&, int)':
plants.cpp:10:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = count; i < r.size(); i ++)
      |                      ~~^~~~~~~~~~
plants.cpp: In function 'void init(int, idata)':
plants.cpp:25:6: warning: unused variable 's' [-Wunused-variable]
   25 |  int s = 0;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 133 ms 4904 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 5 ms 316 KB Output is correct
10 Correct 136 ms 4892 KB Output is correct
11 Correct 113 ms 4836 KB Output is correct
12 Correct 111 ms 5040 KB Output is correct
13 Correct 163 ms 4888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 133 ms 4904 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 5 ms 316 KB Output is correct
10 Correct 136 ms 4892 KB Output is correct
11 Correct 113 ms 4836 KB Output is correct
12 Correct 111 ms 5040 KB Output is correct
13 Correct 163 ms 4888 KB Output is correct
14 Correct 1082 ms 5072 KB Output is correct
15 Execution timed out 4051 ms 6720 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 52 ms 3048 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Incorrect 1 ms 296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -