답안 #420069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420069 2021-06-08T04:49:17 Z Apiram 식물 비교 (IOI20_plants) C++14
0 / 100
12 ms 19096 KB
#include<bits/stdc++.h>
using namespace std;
int inf = 2000000;
vector<set<int>>great(200000);
vector<set<int>>les(200000);
void init(int k, std::vector<int> r) {
	vector<pair<int,int>>arr;
	for (int i =0;i<r.size();++i){
	arr.push_back({r[i],i});
	}
	sort(arr.begin(),arr.end());
	int i =0;
	while(i<arr.size()&&arr[i].first==0){
	 	for (int j=1;j<k;++j){
	 	great[arr[i].second].insert((arr[i].second+j)%arr.size());
	 	les[(arr[i].second+j)%arr.size()].insert(arr[i].second);
	 	}
	 	++i;
	}
	bool ok=false;
	while(!ok){
		ok=true;
	for (int j =i;j<arr.size();++j){
	    int counts=0;
	    vector<int>ans;
	      for (int l=1;l<k;++l){
	          if (great[(arr[j].second+l)%arr.size()].find(j)==great[(arr[j].second+l)%arr.size()].end()){
	          ans.push_back((arr[j].second+l)%arr.size());
	          }
	          else counts++;    
	      }
	      if (ans.size()<=(arr[i].first-counts)&&!ans.empty()){
	      for (auto x:ans){
	      les[j].insert(x);
	      great[x].insert(j);
	      ok=false;
	      }}
	}}		
}

int compare_plants(int x, int y) {
	if (great[x].find(y)!=great[x].end())return 1;
	else if (les[x].find(y)!=les[x].end())return -1;
	else return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:8:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i =0;i<r.size();++i){
      |                ~^~~~~~~~~
plants.cpp:13:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  while(i<arr.size()&&arr[i].first==0){
      |        ~^~~~~~~~~~~
plants.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int j =i;j<arr.size();++j){
      |                ~^~~~~~~~~~~
plants.cpp:32:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |        if (ans.size()<=(arr[i].first-counts)&&!ans.empty()){
      |            ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 19020 KB Output is correct
2 Correct 12 ms 19020 KB Output is correct
3 Incorrect 11 ms 18980 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct
3 Incorrect 11 ms 19020 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct
3 Incorrect 11 ms 19020 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 19020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19020 KB Output is correct
2 Correct 12 ms 19096 KB Output is correct
3 Incorrect 12 ms 19064 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 19020 KB Output is correct
2 Correct 11 ms 19004 KB Output is correct
3 Incorrect 12 ms 19020 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 19020 KB Output is correct
2 Correct 12 ms 19020 KB Output is correct
3 Incorrect 11 ms 18980 KB Output isn't correct
4 Halted 0 ms 0 KB -