Submission #397246

# Submission time Handle Problem Language Result Execution time Memory
397246 2021-05-01T18:33:39 Z Antekb Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 344 KB
#include "plants.h"
#include<bits/stdc++.h>
#define pb(x) push_back(x)
using namespace std;
vector<int> V, V2;
void init(int k, std::vector<int> r) {
    int n=r.size();
    k--;
    V.resize(n);
    auto r2=r;
    for(int i=0; i<n; i++){
    	vector<int> V2;
    	for(int j=0; j<n; j++){
    		if(r2[j]==k){
    			V2.push_back(j);
    		}
    	}
    	int j=V2[0];
    	if(V2.size()>1){
    		for(int l=0; l<V2.size(); l++)if(((V2[l+1]-V2[l]+n)%n)>k)j=V2[l];
    	}
    	V[j]=i;
    	r2[j]=-1;
    	for(int l=1; l<=k; l++){
			r2[(j-l+n)%n]++;
		}
	}
	return;
}     
int compare_plants(int x, int y){
	if(V[x]<V[y])return -1;
	if(V[x]>V[y])return 1;
   	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |       for(int l=0; l<V2.size(); l++)if(((V2[l+1]-V2[l]+n)%n)>k)j=V2[l];
      |                    ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -