Submission #470062

# Submission time Handle Problem Language Result Execution time Memory
470062 2021-09-02T20:01:50 Z MohamedFaresNebili Cake (CEOI14_cake) C++14
15 / 100
2000 ms 4016 KB
#include <bits/stdc++.h>

using namespace std;

using ll  = long long;
using ld  = long double;
using vl  = vector<long long>;

#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()

const ll MOD = 998244353;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;

int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll n, m, q; cin>>n>>m; ll arr[n+2]; arr[0]=INT_MAX, arr[n+1]=INT_MAX;
    for(int l=1;l<=n;l++) cin>>arr[l];
    cin>>q; vector<bool> edge(n+2, false); edge[m]=true;
    while(q--) {
        char ch; cin>>ch;
        if(ch=='F') {
            ll ans=0; ll a; cin>>a; ll l=m-1, r=m+1, next=m;
            while(l>=1||r<=n) {
                if(next==a) break;
                ans++;
                if(arr[l]<arr[r]) next=l--;
                else next=r++;
            }
            cout<<ans<<'\n';
        }
        else if(ch=='E') {
            ll a, b; cin>>a>>b;
            for(int l=1;l<=n;l++) {
                if(l==a) continue;
                if(n-arr[l]+1>=b&&n-arr[l]+1<n-arr[a]+1) arr[l]--;
            }
            arr[a]=n-b+1;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 13 ms 204 KB Output is correct
5 Correct 259 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 1128 KB Time limit exceeded
2 Execution timed out 2076 ms 1400 KB Time limit exceeded
3 Execution timed out 2076 ms 1388 KB Time limit exceeded
4 Execution timed out 2078 ms 1804 KB Time limit exceeded
5 Execution timed out 2093 ms 644 KB Time limit exceeded
6 Execution timed out 2081 ms 744 KB Time limit exceeded
7 Execution timed out 2089 ms 740 KB Time limit exceeded
8 Execution timed out 2085 ms 1000 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 1328 KB Time limit exceeded
2 Execution timed out 2091 ms 1260 KB Time limit exceeded
3 Execution timed out 2099 ms 1268 KB Time limit exceeded
4 Correct 1 ms 204 KB Output is correct
5 Execution timed out 2088 ms 2440 KB Time limit exceeded
6 Execution timed out 2078 ms 2544 KB Time limit exceeded
7 Execution timed out 2095 ms 2384 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 374 ms 672 KB Output is correct
2 Correct 595 ms 612 KB Output is correct
3 Execution timed out 2083 ms 1068 KB Time limit exceeded
4 Execution timed out 2095 ms 1156 KB Time limit exceeded
5 Correct 722 ms 1096 KB Output is correct
6 Execution timed out 2079 ms 840 KB Time limit exceeded
7 Execution timed out 2083 ms 1268 KB Time limit exceeded
8 Execution timed out 2091 ms 1080 KB Time limit exceeded
9 Execution timed out 2086 ms 2276 KB Time limit exceeded
10 Execution timed out 2095 ms 4016 KB Time limit exceeded
11 Execution timed out 2089 ms 824 KB Time limit exceeded
12 Execution timed out 2096 ms 1888 KB Time limit exceeded
13 Execution timed out 2090 ms 2416 KB Time limit exceeded