답안 #431515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431515 2021-06-17T12:35:42 Z Hazem 식물 비교 (IOI20_plants) C++14
5 / 100
111 ms 5736 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

int k;
vector<int>a,pr;

void init(int K, std::vector<int> r) {
	
	k = k;a = pr = r;
	for(int i=1;i<a.size();i++)
		pr[i] += pr[i-1];

	return;
}

bool check(int x,int y){

	if(y>x)
		return (pr[y-1]-(x?pr[x-1]:0))==(y-x);
	else 
		return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y);
}

bool check1(int x,int y){
	
	if(y>x)
		return (pr[y-1]-(x?pr[x-1]:0))==0;
	else 
		return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==0;
}

int compare_plants(int x, int y) {
	
	if(check(x,y)||check1(y,x))
		return -1;

	if(check(y,x)||check1(x,y))
		return 1;

	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=1;i<a.size();i++)
      |              ~^~~~~~~~~
plants.cpp: In function 'bool check(int, int)':
plants.cpp:23:43: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y);
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 80 ms 3012 KB Output is correct
7 Correct 69 ms 3328 KB Output is correct
8 Correct 99 ms 5704 KB Output is correct
9 Correct 103 ms 5704 KB Output is correct
10 Correct 92 ms 5700 KB Output is correct
11 Correct 101 ms 5728 KB Output is correct
12 Correct 90 ms 5660 KB Output is correct
13 Correct 111 ms 5728 KB Output is correct
14 Correct 101 ms 5736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 240 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 80 ms 3012 KB Output is correct
7 Correct 69 ms 3328 KB Output is correct
8 Correct 99 ms 5704 KB Output is correct
9 Correct 103 ms 5704 KB Output is correct
10 Correct 92 ms 5700 KB Output is correct
11 Correct 101 ms 5728 KB Output is correct
12 Correct 90 ms 5660 KB Output is correct
13 Correct 111 ms 5728 KB Output is correct
14 Correct 101 ms 5736 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -