Submission #751735

#TimeUsernameProblemLanguageResultExecution timeMemory
751735tolbiComparing Plants (IOI20_plants)C++17
14 / 100
4058 ms9464 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //Allahuekber //ahmet23 orz... //Sani buyuk Osman Pasa Plevneden cikmam diyor. //FatihSultanMehmedHan //YavuzSultanSelimHan //AbdulhamidHan #define author tolbi #include <bits/stdc++.h> using namespace std; template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;} template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;} template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;} template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;} template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;} template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;} #define int long long #define endl '\n' #define vint(x) vector<int> x #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define cinarr(x) for (auto &it : x) cin>>it; #define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl; #define sortarr(x) sort(x.begin(),x.end()) #define sortrarr(x) sort(x.rbegin(),x.rend()) #define det(x) cout<<"NO\0YES"+x*3<<endl; #define INF LONG_LONG_MAX #define rev(x) reverse(x.begin(),x.end()); #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define tol(bi) (1LL<<((int)(bi))) const int MOD = 1e9+7; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #ifdef tolbi #else #include "plants.h" #endif vector<int> arr; void init(int32_t k, vector<int32_t> r) { int n = r.size(); arr.resize(n); for (int i = 0; i < n; i++){ int pos=23; for (int j = 0; j < n; j++){ if (r[j]==0){ pos=j; break; } } int lel = 0; for (int j = 1; j <= n; j++){ if (r[(j+pos)%n]==0 && j-lel>=k){ pos=(j+pos)%n; break; } if (r[(j+pos)%n]==0) lel = j; } for (int j = 0; j < k; j++){ r[(pos+n-j)%n]--; } arr[pos]=i; } } int32_t compare_plants(int32_t x, int32_t y) { if (arr[x]<arr[y]) return 1; return -1; } #ifdef tolbi static int32_t n, k, q; static vector<int32_t> r; static vector<int32_t> x; static vector<int32_t> y; static vector<int32_t> answer; int32_t main() { assert(scanf("%d%d%d", &n, &k, &q) == 3); r.resize(n); answer.resize(q); for (int32_t i = 0; i < n; i++) { int32_t value; assert(scanf("%d", &value) == 1); r[i] = value; } x.resize(q); y.resize(q); for (int32_t i = 0; i < q; i++) { assert(scanf("%d%d", &x[i], &y[i]) == 2); } fclose(stdin); init(k, r); for (int32_t i = 0; i < q; i++) { answer[i] = compare_plants(x[i], y[i]); } for (int32_t i = 0; i < q; i++) { printf("%d\n", answer[i]); } fclose(stdout); return 0; } #endif

Compilation message (stderr)

plants.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
#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...