Submission #1050437

#TimeUsernameProblemLanguageResultExecution timeMemory
1050437MercubytheFirstComparing Plants (IOI20_plants)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "plants.h" template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a); template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v); template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p); template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s); template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s); using namespace std; int n; vector<int> group, big; void init(int k, std::vector<int> r) { big = r; n = r.size(); group.assign(n, -1); vector<bool> used(n); for(int round = 0; round < n; ++round) { int nonzero = 0; vector<int> cur; for(int idx = 0; idx < 2*n; ++idx) { int i = idx % n; if(used[i]) { // assert(big[i] <= 0); nonzero += 1; continue; } else if(big[i] > 0) { nonzero += 1; } else if(big[i] == 0) { if(nonzero >= k - 1) { // used[i] = true; group[i] = round; cur.push_back(i); } nonzero = 0; } // else assert(false); } for(int x : cur) { used[x] = true; int start_idx = (x + n - k + 1) % n; for(int i = start_idx; i != x; i = (i + 1) % n) { // assert(used[i] or big[i] != 0); big[i]--; } } } // for(int x : group) // cout << x << ' '; // cout << endl; } int compare_plants(int x, int y) { // assert(group[x] != -1 and group[y] != -1); if(group[x] < group[y]) { return 1; } else if(group[x] > group[y]) { return -1; } else { assert(group[x] == group[y]); return 0; } } template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) { os << "["; for(size_t i = 0; i + 1 < N; ++i) { os << a[i] << ", "; } if(N > 0) os << a[N - 1]; os << "]"; return os; } template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { os << "(" << p.first << ", " << p.second << ") "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { os << '['; for(auto x : v) os << x << ", "; os << "] "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } // template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } /* 7 4 5 1 0 0 0 1 2 3 0 1 0 2 0 3 3 4 4 5 */
#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...