Submission #1050014

#TimeUsernameProblemLanguageResultExecution timeMemory
1050014MercubytheFirstComparing Plants (IOI20_plants)C++17
0 / 100
0 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 nonz = 0; vector<int> did; for(int idx = 0; idx < 3*n; ++idx) { int i = idx%n; if(used[i]) { assert(big[i] == 0); nonz++; continue; } if(big[i] > 0) { nonz++; } else if(big[i] == 0) { if(nonz >= k - 1) { used[i] = true; did.push_back(i); group[i] = n - round; } nonz = 0; } else assert(false); } if(did.empty()) { assert(count(used.begin(), used.end(), true) == n); break; } for(int x : did) { int start = (((x - k + 1) % n + n) % n); for(int i = start; i != x; i = (i + 1) % n) { if(used[i]) { continue; } assert(big[i] > 0); --big[i]; } } } // cout << group << endl; } int compare_plants(int x, int y) { 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; }
#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...