Submission #652914

# Submission time Handle Problem Language Result Execution time Memory
652914 2022-10-25T06:51:06 Z coding_snorlax Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 308 KB
#include<bits/stdc++.h>
#include "plants.h"
using namespace std;
int Answer[5005];
void init(int k,vector<int> r){
    int Total=(int)r.size();
    vector<int> zero;
    int Count=0;
    int Mark[5005]={0};
    int now;
    for(int j=0;j<(int)r.size();j++){
        zero.clear();
        for(int i=0;i<(int)r.size();i++){
            if ((!r[i]) && (!Mark[i])){
                zero.push_back(i);

            }
        }
        int first=zero[int(zero.size())-1]-Total;
        for(int i=0;i<(int)zero.size();i++){
            if(zero[i]-first>=k){
                now=zero[i];
                break;
            }
            else first=zero[i];
        }
        Answer[now]=Count;
        Mark[now]=1;
        for(int i=now+Total;i>now+Total-k;i--){
            r[i%Total]--;
        }
        Count++;
    }

}
int compare_plants(int x,int y){
    if(Answer[x]>Answer[y]) return 1;
    else return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:29:17: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |         for(int i=now+Total;i>now+Total-k;i--){
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -