# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
676572 |
2022-12-31T10:15:35 Z |
vjudge1 |
Cake (CEOI14_cake) |
C++17 |
|
2000 ms |
7192 KB |
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl "\n"
const int mod = (int) 1e9+7;
const int N=2e5+5;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,a; cin>>n>>a;
int d[n+5],opd[n+5];
for (int i=1;i<=n;i++) {
cin>>d[i];
opd[d[i]]=i;
}
int when[n+5];
when[a]=0;
int l=a-1,r=a+1,time=1;
while (time<n) {
if (l>=1 && ((r>n) || (r<=n && d[l]<d[r]))) {
when[l]=time; time++; l--;
}
if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
when[r]=time; time++; r++;
}
}
int q; cin>>q;
while (q--) {
char c; cin>>c;
if (c=='F') {
int x; cin>>x;
cout<<when[x]<<endl;
}
else {
int x,nw; cin>>x>>nw;
nw=n-(nw-1);
for (int i=1;i<=n;i++) {
if (d[i]>d[x] && d[i]<=nw) d[i]--;
}
d[x]=nw;
//for (int i=1;i<=n;i++) cout<<d[i]<<' '; cout<<endl;
int l=a-1,r=a+1,time=1;
while (time<n) {
if (l>=1 && ((r>n) || (r<=n && d[l]<d[r]))) {
when[l]=time; time++; l--;
}
if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
when[r]=time; time++; r++;
}
}
}
}
}
Compilation message
cake.cpp: In function 'int main()':
cake.cpp:12:16: warning: variable 'opd' set but not used [-Wunused-but-set-variable]
12 | int d[n+5],opd[n+5];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
12 ms |
376 KB |
Output is correct |
5 |
Correct |
249 ms |
660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2045 ms |
828 KB |
Time limit exceeded |
2 |
Execution timed out |
2064 ms |
972 KB |
Time limit exceeded |
3 |
Execution timed out |
2066 ms |
828 KB |
Time limit exceeded |
4 |
Execution timed out |
2037 ms |
804 KB |
Time limit exceeded |
5 |
Execution timed out |
2060 ms |
1164 KB |
Time limit exceeded |
6 |
Execution timed out |
2058 ms |
1252 KB |
Time limit exceeded |
7 |
Execution timed out |
2074 ms |
1312 KB |
Time limit exceeded |
8 |
Execution timed out |
2082 ms |
1032 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
3636 KB |
Output is correct |
2 |
Correct |
43 ms |
3552 KB |
Output is correct |
3 |
Correct |
44 ms |
3508 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
114 ms |
7192 KB |
Output is correct |
6 |
Correct |
110 ms |
7160 KB |
Output is correct |
7 |
Correct |
82 ms |
6912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
736 KB |
Output is correct |
2 |
Correct |
589 ms |
1008 KB |
Output is correct |
3 |
Execution timed out |
2086 ms |
2124 KB |
Time limit exceeded |
4 |
Execution timed out |
2088 ms |
2240 KB |
Time limit exceeded |
5 |
Correct |
698 ms |
1328 KB |
Output is correct |
6 |
Execution timed out |
2047 ms |
2292 KB |
Time limit exceeded |
7 |
Execution timed out |
2068 ms |
1316 KB |
Time limit exceeded |
8 |
Execution timed out |
2052 ms |
3132 KB |
Time limit exceeded |
9 |
Execution timed out |
2079 ms |
6520 KB |
Time limit exceeded |
10 |
Execution timed out |
2021 ms |
2020 KB |
Time limit exceeded |
11 |
Execution timed out |
2070 ms |
1124 KB |
Time limit exceeded |
12 |
Execution timed out |
2059 ms |
5252 KB |
Time limit exceeded |
13 |
Execution timed out |
2056 ms |
6560 KB |
Time limit exceeded |