Submission #676599

# Submission time Handle Problem Language Result Execution time Memory
676599 2022-12-31T11:50:23 Z vjudge1 Cake (CEOI14_cake) C++17
0 / 100
2000 ms 12580 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#define int long long
#define endl '\n'
#define mod 1000000007;
using namespace std;

int A[250001]; pair<int,int> P[250001];
int seg[1<<20];
int N,Left,Right,V;
int plc[151],s[151];
map<int,int>cc[151];
vector<int>d[151];
int vs[250001];
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,a; cin >> n >> a;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        P[i].first = A[i];
        P[i].second = i + 1;
    }
    sort(P,P+n);
    deque<int>tp;
    for(int i = 1; i <= min(n,(int)10); i++) tp.push_back(P[i - 1].second);
    deque<int>ee;
    for(int i = 11; i <= n; i++) ee.push_back(P[i - 1].second);
    
    
    int t; cin >> t;
    while(t--){
        char x; int c,d; cin >> x >> c;
        if(x == 'E'){
            cin >> d;
            int plc = -1, new_val = n - d + 1;
            for(int i = 0; i < min(n,(int)10); i++){
                if(tp[i] == c){
                    plc = i;
                }
            }
            if(new_val == plc + 1) continue;
            deque<int>nw;
            for(int i = 0; i < min(n,(int)10); i++){
                if(i + 1 == new_val){
                    nw.push_back(c);
                }
                if(plc != -1){
                    if(tp[i] != c)  nw.push_back(tp[i]);
                }else if(i != 9 && tp[i] != c) nw.push_back(tp[i]);
            }
            if(plc == -1){
                ee.push_front(tp[9]);
            }
            tp = nw;
            
        }else{
            int ct = 0;
            for(int i = 0; i < min(n,(int)10); i++){
                A[tp[i]] = i + 1;
                vs[tp[i]] = 1;
            }
            deque<int>nw;
            for(int i = 0; i < ee.size(); i++){
                if(!vs[ee[i]]) {
                    A[ee[i]] = ct + 11;
                    nw.push_back(ee[i]);
                    ct++;
                }
                vs[ee[i]] = 1;
            }
            for(int i = 1; i <= n; i++) vs[i] = 0;
            ee = nw;
            c--;
            int l = a - 2, r = a, cnt = 0;
            if(a - 1 == c){
                cout << 0 << endl;
                continue;
            }
            while(1){
                int mx1 = 1e18, mx2 = 1e18;
                cnt++;
                if(l >= 0){
                    mx1 = A[l];
                }
                if(r < n){
                    mx2 = A[r];
                }
                if(mx1 < mx2){
                    if(l == c) break;
                    l--;
                }else{
                    if(r == c) break;
                    r++;
                }
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:148:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |             for(int i = 0; i < ee.size(); i++){
      |                            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 70 ms 1508 KB Execution killed with signal 11
2 Incorrect 194 ms 916 KB Output isn't correct
3 Runtime error 165 ms 1516 KB Execution killed with signal 11
4 Incorrect 215 ms 852 KB Output isn't correct
5 Incorrect 289 ms 1584 KB Output isn't correct
6 Incorrect 263 ms 1620 KB Output isn't correct
7 Incorrect 265 ms 1624 KB Output isn't correct
8 Incorrect 346 ms 1596 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 5340 KB Time limit exceeded
2 Execution timed out 2084 ms 5308 KB Time limit exceeded
3 Execution timed out 2087 ms 5272 KB Time limit exceeded
4 Correct 0 ms 340 KB Output is correct
5 Execution timed out 2089 ms 12488 KB Time limit exceeded
6 Execution timed out 2080 ms 12464 KB Time limit exceeded
7 Execution timed out 2080 ms 12464 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Runtime error 903 ms 952 KB Execution killed with signal 11
2 Execution timed out 2081 ms 852 KB Time limit exceeded
3 Execution timed out 2079 ms 2884 KB Time limit exceeded
4 Execution timed out 2088 ms 2908 KB Time limit exceeded
5 Runtime error 345 ms 704 KB Execution killed with signal 11
6 Execution timed out 2088 ms 3680 KB Time limit exceeded
7 Execution timed out 2088 ms 968 KB Time limit exceeded
8 Execution timed out 2088 ms 5364 KB Time limit exceeded
9 Execution timed out 2083 ms 12580 KB Time limit exceeded
10 Runtime error 1723 ms 1024 KB Execution killed with signal 11
11 Execution timed out 2073 ms 1616 KB Time limit exceeded
12 Execution timed out 2085 ms 10040 KB Time limit exceeded
13 Execution timed out 2091 ms 12524 KB Time limit exceeded