Submission #101139

#TimeUsernameProblemLanguageResultExecution timeMemory
101139square1001Cake (CEOI14_cake)C++14
35 / 100
2100 ms5964 KiB
#include <string> #include <vector> #include <iostream> #include <algorithm> #include <functional> using namespace std; const int inf = 1012345678; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N, A, Q; cin >> N >> A; --A; vector<int> d(N); for (int i = 0; i < N; ++i) cin >> d[i]; function<vector<int>(void)> get_perm = [&]() { vector<int> ans(N); int L = A - 1, R = A + 1; for (int i = 1; i < N; ++i) { int getl = (L == -1 ? inf : d[L]); int getr = (R == N ? inf : d[R]); if (getl < getr) ans[L] = i, --L; else ans[R] = i, ++R; } return ans; }; vector<int> perm = get_perm(); cin >> Q; for (int i = 0; i < Q; ++i) { string tp; cin >> tp; if (tp == "E") { int pos, e; cin >> pos >> e; --pos, --e; for (int j = 0; j < N; ++j) { if (d[pos] < d[j] && d[j] <= N - e) { --d[j]; } } d[pos] = N - e; perm = get_perm(); } else { int pos; cin >> pos; --pos; cout << perm[pos] << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...