Submission #10648117


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<tuple>
#include<deque>

using namespace std;
int main()
{
    string s;
    int q;
    cin>>s>>q;
    
    map<int,tuple<char,int,int>>ma;
    int ri=0;
    for(int i=0;i<q;++i){
        int qi;cin>>qi;
        if(qi==1){
            ++ri;
        }
        else{
            int fi;char ci;
            cin>>fi>>ci;
            ma[i]=make_tuple(ci,fi,ri);
        }
    }
    
    if(ri%2==1)reverse(s.begin(),s.end());
    deque<char>ds;
    for(auto c:s)ds.push_back(c);
    
    for(auto e:ma){
        tuple<char,int,int>v=e.second;
        if(((ri-get<2>(v))%2==1&&get<1>(v)==2)||((ri-get<2>(v))%2==0&&get<1>(v)==1))
            ds.push_front(get<0>(v));
        else
            ds.push_back(get<0>(v));
    }
    
    for(auto c:ds)cout<<c;
    cout<<endl;
    
    return 0;
}

Submission Info

Submission Time
Task D - String Formation
User NB29979
Language C++14 (GCC 5.4.1)
Score 400
Code Size 908 Byte
Status AC
Exec Time 181 ms
Memory 13440 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 24
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 1 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 1 ms 256 KB
11.txt AC 179 ms 13440 KB
12.txt AC 181 ms 13440 KB
13.txt AC 178 ms 13440 KB
14.txt AC 163 ms 12160 KB
15.txt AC 162 ms 12160 KB
16.txt AC 163 ms 12160 KB
17.txt AC 161 ms 12160 KB
18.txt AC 158 ms 12160 KB
19.txt AC 125 ms 9088 KB
20.txt AC 124 ms 9088 KB
21.txt AC 124 ms 9088 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB