Submission #521740

# Submission time Handle Problem Language Result Execution time Memory
521740 2022-02-02T21:52:54 Z A_D Comparing Plants (IOI20_plants) C++14
14 / 100
4000 ms 8728 KB
#include "plants.h"

#include <bits/stdc++.h>
using namespace std;
const int NN=2e5+100;
int a[NN];
int nn;

void init(int k,vector<int> r){
    nn=r.size();
    int cnt=nn;
    vector<int> vec;
    while(1){
        vec.clear();
        for(int i=0;i<nn;i++){
            if(r[i]==0){
                vec.push_back(i);
            }
        }
        if(vec.empty())break;
        reverse(vec.begin(),vec.end());
        vec.push_back(vec[0]);
        reverse(vec.begin(),vec.end());
        int j;
        int cn=0;
//        cout<<"vector\n";
  //      for(auto x:vec)cout<<x<<" ";cout<<endl;
        for(int i=1;i<vec.size();i++){
            if((vec[i]-vec[i-1]+nn)%nn+1>k){
                j=vec[i];
//                cout<<j<<" ";
                cn++;
            }
        }
   //     cout<<endl;
     //   cout<<cn<<endl;
       // cout<<j<<endl;
        if(cn>1)assert(0);
        if(vec.size()==2)j=vec[0];
        a[j]=cnt--;
        int h=k;
        while(h--){
            r[j]--;j--;j+=nn;j%=nn;
        }
//        for(int i=0;i<nn;i++)cout<<a[i]<<" ";cout<<endl;
  //      for(int i=0;i<nn;i++)cout<<r[i]<<" ";cout<<endl;
    }
}

int compare_plants(int x, int y){
	if(a[x]<a[y])return -1;
	else return 1;

}


Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=1;i<vec.size();i++){
      |                     ~^~~~~~~~~~~
plants.cpp:40:13: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |         a[j]=cnt--;
      |         ~~~~^~~~~~
# Verdict Execution time Memory 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 Runtime error 1 ms 416 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 204 KB Output is correct
6 Correct 10 ms 332 KB Output is correct
7 Correct 250 ms 5072 KB Output is correct
8 Correct 2 ms 312 KB Output is correct
9 Correct 10 ms 316 KB Output is correct
10 Correct 245 ms 5096 KB Output is correct
11 Correct 247 ms 5100 KB Output is correct
12 Correct 195 ms 5096 KB Output is correct
13 Correct 279 ms 5000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 204 KB Output is correct
6 Correct 10 ms 332 KB Output is correct
7 Correct 250 ms 5072 KB Output is correct
8 Correct 2 ms 312 KB Output is correct
9 Correct 10 ms 316 KB Output is correct
10 Correct 245 ms 5096 KB Output is correct
11 Correct 247 ms 5100 KB Output is correct
12 Correct 195 ms 5096 KB Output is correct
13 Correct 279 ms 5000 KB Output is correct
14 Correct 2513 ms 5496 KB Output is correct
15 Execution timed out 4014 ms 8728 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 460 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 460 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Runtime error 1 ms 416 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -