Submission #676598

# Submission time Handle Problem Language Result Execution time Memory
676598 2022-12-31T11:47:53 Z vjudge1 Cake (CEOI14_cake) C++17
0 / 100
2000 ms 14356 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{
            
            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]] = i + 11;
                    nw.push_back(ee[i]);
                }
                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 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 73 ms 2964 KB Execution killed with signal 11
2 Incorrect 195 ms 4300 KB Output isn't correct
3 Runtime error 169 ms 4888 KB Execution killed with signal 11
4 Incorrect 220 ms 4128 KB Output isn't correct
5 Incorrect 313 ms 6344 KB Output isn't correct
6 Incorrect 275 ms 6404 KB Output isn't correct
7 Incorrect 263 ms 6432 KB Output isn't correct
8 Incorrect 347 ms 6292 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 6212 KB Time limit exceeded
2 Execution timed out 2069 ms 6204 KB Time limit exceeded
3 Execution timed out 2074 ms 6140 KB Time limit exceeded
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2083 ms 14284 KB Time limit exceeded
6 Execution timed out 2072 ms 14092 KB Time limit exceeded
7 Execution timed out 2076 ms 14356 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Runtime error 918 ms 1292 KB Execution killed with signal 11
2 Execution timed out 2063 ms 1236 KB Time limit exceeded
3 Execution timed out 2084 ms 3484 KB Time limit exceeded
4 Execution timed out 2088 ms 3404 KB Time limit exceeded
5 Runtime error 345 ms 1112 KB Execution killed with signal 11
6 Execution timed out 2071 ms 4352 KB Time limit exceeded
7 Execution timed out 2090 ms 1236 KB Time limit exceeded
8 Execution timed out 2080 ms 7092 KB Time limit exceeded
9 Execution timed out 2051 ms 14300 KB Time limit exceeded
10 Runtime error 1749 ms 1748 KB Execution killed with signal 11
11 Execution timed out 2093 ms 1764 KB Time limit exceeded
12 Execution timed out 2091 ms 11420 KB Time limit exceeded
13 Execution timed out 2085 ms 14256 KB Time limit exceeded