Submission #1051431

#TimeUsernameProblemLanguageResultExecution timeMemory
1051431pccComparing Plants (IOI20_plants)C++17
14 / 100
4067 ms12788 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int mxn = 4e5+10; #define pii pair<int,int> #define fs first #define sc second int arr[mxn]; int N; int K; int perm[mxn]; bitset<mxn> done; int dp[mxn]; void calc(int id){ fill(dp,dp+N*2,0); for(int i = 0;i<N*2;i++){ if(i)dp[i] = (arr[i-1]?dp[i-1]:0); dp[i]++; } int tar = 0; for(int i = 0;i<N*2;i++){ if(!arr[i]&&dp[i]>=K)tar = i%N; } perm[tar] = id; arr[tar] = arr[tar+N] = mxn; for(int i = 0;i<K;i++){ int pre = (tar+N-i)%N; arr[pre]--;arr[pre+N]--; } return; } void init(int k, std::vector<int> r) { K = k; N = r.size(); for(int i = 0;i<N;i++)arr[i] = arr[i+N] = r[i]; for(int i = N-1;i>=0;i--)calc(i); } int compare_plants(int x, int y) { return (perm[x]>perm[y]?1:-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...