Submission #470061

# Submission time Handle Problem Language Result Execution time Memory
470061 2021-09-02T19:37:38 Z MohamedFaresNebili Cake (CEOI14_cake) C++14
0 / 100
2000 ms 6292 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;
    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') {
            vector<bool>visited(n+2); visited=edge;
            ll ans=0, next=m; ll a; cin>>a;
            while(next!=a) {
                ll cnt=0;
                for(int l=1;l<=n;l++) {
                    if(visited[l]) continue;
                    if(visited[l+1]||visited[l-1]) {
                        cnt=(arr[l]<=arr[cnt]?l:cnt);
                    }
                }
                ans++; next=cnt; visited[cnt]=true;
            }
            cout<<ans<<'\n';
        }
        else if(ch=='E') {
            ll a, b; cin>>a>>b; vl ar;
            for(int l=1;l<=n;l++) ar.pb(arr[l]);
            sort(all(ar), greater<ll>());
            arr[a]=ar[b-1]+1;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 588 KB Time limit exceeded
2 Execution timed out 2056 ms 780 KB Time limit exceeded
3 Execution timed out 2074 ms 864 KB Time limit exceeded
4 Execution timed out 2080 ms 612 KB Time limit exceeded
5 Execution timed out 2081 ms 1100 KB Time limit exceeded
6 Execution timed out 2077 ms 1312 KB Time limit exceeded
7 Execution timed out 2081 ms 1252 KB Time limit exceeded
8 Execution timed out 2097 ms 1004 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 1100 KB Time limit exceeded
2 Execution timed out 2094 ms 1100 KB Time limit exceeded
3 Execution timed out 2090 ms 1100 KB Time limit exceeded
4 Incorrect 1 ms 204 KB Output isn't correct
5 Execution timed out 2077 ms 2272 KB Time limit exceeded
6 Execution timed out 2076 ms 2252 KB Time limit exceeded
7 Execution timed out 2063 ms 2252 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 332 KB Time limit exceeded
2 Execution timed out 2078 ms 332 KB Time limit exceeded
3 Execution timed out 2077 ms 1356 KB Time limit exceeded
4 Execution timed out 2076 ms 1348 KB Time limit exceeded
5 Execution timed out 2087 ms 332 KB Time limit exceeded
6 Execution timed out 2082 ms 2372 KB Time limit exceeded
7 Execution timed out 2080 ms 712 KB Time limit exceeded
8 Execution timed out 2084 ms 2968 KB Time limit exceeded
9 Execution timed out 2078 ms 6292 KB Time limit exceeded
10 Execution timed out 2080 ms 332 KB Time limit exceeded
11 Execution timed out 2083 ms 844 KB Time limit exceeded
12 Execution timed out 2090 ms 5404 KB Time limit exceeded
13 Execution timed out 2079 ms 2256 KB Time limit exceeded