Submission #769034

#TimeUsernameProblemLanguageResultExecution timeMemory
769034t6twotwoComparing Plants (IOI20_plants)C++17
14 / 100
4083 ms9880 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int N, K; vector<int> R, A; int dis(int x, int y) { if (x < y) { return y - x; } else { return N - x + y; } } void init(int k, std::vector<int> r) { K = k, R = r; N = R.size(); A.resize(N, -1); for (int i = 0; i < N; i++) { vector<int> v; for (int j = 0; j < N; j++) { if (A[j] == -1 && R[j] == K - 1) { v.push_back(j); } } int m = v.size(), p; if (m == 1) { p = v[0]; } else { for (int j = 0; j < m; j++) { if (dis(v[j], v[(j + 1) % m]) >= K) { p = v[(j + 1) % m]; } } } A[p] = i; for (int j = 1; j < K; j++) { R[(p - j + N) % N]++; } } } int compare_plants(int x, int y) { return A[x] > A[y] ? 1 : -1; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:34:6: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |   A[p] = i;
      |      ^
#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...