Submission #101139

# Submission time Handle Problem Language Result Execution time Memory
101139 2019-03-17T04:53:28 Z square1001 Cake (CEOI14_cake) C++14
35 / 100
2000 ms 5964 KB
#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 time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 20 ms 384 KB Output is correct
5 Correct 317 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 1108 KB Time limit exceeded
2 Execution timed out 2055 ms 1148 KB Time limit exceeded
3 Execution timed out 2055 ms 1128 KB Time limit exceeded
4 Execution timed out 2009 ms 1084 KB Time limit exceeded
5 Execution timed out 2043 ms 1036 KB Time limit exceeded
6 Execution timed out 2029 ms 1164 KB Time limit exceeded
7 Execution timed out 2019 ms 1040 KB Time limit exceeded
8 Execution timed out 2033 ms 1272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 105 ms 3556 KB Output is correct
2 Correct 61 ms 3280 KB Output is correct
3 Correct 85 ms 3368 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 186 ms 5964 KB Output is correct
6 Correct 193 ms 5964 KB Output is correct
7 Correct 182 ms 5708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 481 ms 888 KB Output is correct
2 Correct 796 ms 1124 KB Output is correct
3 Execution timed out 2013 ms 1728 KB Time limit exceeded
4 Execution timed out 2063 ms 1756 KB Time limit exceeded
5 Correct 986 ms 2048 KB Output is correct
6 Execution timed out 2037 ms 1904 KB Time limit exceeded
7 Execution timed out 2040 ms 1672 KB Time limit exceeded
8 Execution timed out 2055 ms 2408 KB Time limit exceeded
9 Execution timed out 2049 ms 5196 KB Time limit exceeded
10 Execution timed out 2004 ms 2980 KB Time limit exceeded
11 Execution timed out 2015 ms 1400 KB Time limit exceeded
12 Execution timed out 2060 ms 4292 KB Time limit exceeded
13 Execution timed out 2051 ms 5240 KB Time limit exceeded