Submission #400223

#TimeUsernameProblemLanguageResultExecution timeMemory
400223faresbasbsComparing Plants (IOI20_plants)C++14
0 / 100
69 ms4960 KiB
#include <bits/stdc++.h> #include "plants.h" using namespace std; bool seen[5001]; int val[5001]; void init(int k , vector<int> r){ int n = r.size() , cnt = 0;; for(int i = 0 ; i < n ; i += 1){ int pos; for(int j = 0 ; j < n ; j += 1){ if(seen[j] || r[j]){ continue; } pos = j; } for(int j = 1 ; j < k ; j += 1){ if(seen[(pos-j+n)%n] || r[(pos-j+n)%n]){ continue; } pos = (pos-j+n)%n; break; } val[pos] = cnt++; seen[pos] = 1; for(int j = 1 ; j < k ; j += 1){ if(seen[(pos-j+n)%n]){ continue; } r[(pos-j+n)%n] -= 1; } } } int compare_plants(int x, int y){ if(val[x] < val[y]){ return 1; } return -1; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:25:13: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   seen[pos] = 1;
      |   ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...