Submission #894500

# Submission time Handle Problem Language Result Execution time Memory
894500 2023-12-28T11:18:01 Z zeta7532 Collider (IZhO11_collider) C++17
100 / 100
73 ms 3592 KB
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)

const ll sq=1000;

int main() {
    ll N,M;
    cin >> N >> M;
    string s;
    cin >> s;
    ll cnt=(N+sq-1)/sq;
    vector<string> t(cnt);
    rep(i,M){
        if(i%sq==0){
            if(i>0){
                s.clear();
                rep(j,cnt) s+=t[j],t[j].clear();
            }
            rep(j,N) t[j/sq]+=s[j];
        }
        char c;
        cin >> c;
        if(c=='a'){
            ll x,y;
            cin >> x >> y;
            x--,y--;
            char p;
            rep(j,cnt){
                if(x<t[j].size()){
                    p=t[j][x];
                    t[j].erase(t[j].begin()+x);
                    break;
                }
                x-=t[j].size();
            }
            rep(j,cnt){
                if(y<=t[j].size()){
                    t[j].insert(t[j].begin()+y,p);
                    break;
                }
                y-=t[j].size();
            }
        }
        if(c=='q'){
            ll x;
            cin >> x;
            x--;
            rep(j,cnt){
                if(x<t[j].size()){
                    cout << t[j][x] << endl;
                    break;
                }
                x-=t[j].size();
            }
        }
    }
    return 0;
}

Compilation message

collider.cpp: In function 'int main()':
collider.cpp:39:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                 if(x<t[j].size()){
      |                    ~^~~~~~~~~~~~
collider.cpp:47:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |                 if(y<=t[j].size()){
      |                    ~^~~~~~~~~~~~~
collider.cpp:59:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |                 if(x<t[j].size()){
      |                    ~^~~~~~~~~~~~
collider.cpp:48:49: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |                     t[j].insert(t[j].begin()+y,p);
      |                                                 ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
4 Correct 28 ms 2580 KB Output is correct
5 Correct 45 ms 2576 KB Output is correct
6 Correct 57 ms 2832 KB Output is correct
7 Correct 62 ms 3152 KB Output is correct
8 Correct 34 ms 3148 KB Output is correct
9 Correct 73 ms 3592 KB Output is correct
10 Correct 55 ms 3148 KB Output is correct