Submission #1050171

#TimeUsernameProblemLanguageResultExecution timeMemory
1050171mychecksedadComparing Plants (IOI20_plants)C++17
0 / 100
1 ms360 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define vi vector<int> #define all(x) x.begin(),x.end() const int N = 3e5; int a[N], n; void init(int k, std::vector<int> r) { n = r.size(); for(int i = 0; i < n; ++i) a[i] = 0; if(2*k > n){ int mx = 0; int f = n-1; for(int rep = 0; rep < n; ++rep){ mx = *max_element(all(r)); int l = n, rr = -1; vector<int> L; for(int i = 0; i < n; ++i){ if(r[i] == mx){ L.pb(i); } } int x = L[0]; if(L.size()==1) x = L[0]; else{ for(int i = 0; i + 1 < L.size(); ++i){ if(L[i] + k <= L[i + 1]){ x = L[i + 1]; break; } } } a[x] = f--; r[x] = -n; // cout << x << ' '; // for(int i = x - 1; i > x - k; --i) r[(i+n)%n]--; } // for(int i = 0; i < n; ++i) cout << a[i] << ' '; }else{ } } int compare_plants(int x, int y) { return a[x] < a[y] ? 1 : (a[x] > a[y] ? -1 : 0); }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i + 1 < L.size(); ++i){
      |                    ~~~~~~^~~~~~~~~~
plants.cpp:19:8: warning: unused variable 'l' [-Wunused-variable]
   19 |    int l = n, rr = -1;
      |        ^
plants.cpp:19:15: warning: unused variable 'rr' [-Wunused-variable]
   19 |    int l = n, rr = -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...