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
Exec Time 181 ms
Memory 13440 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
× 3
× 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 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 1 ms 256 KB
06.txt 1 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 1 ms 256 KB
10.txt 1 ms 256 KB
11.txt 179 ms 13440 KB
12.txt 181 ms 13440 KB
13.txt 178 ms 13440 KB
14.txt 163 ms 12160 KB
15.txt 162 ms 12160 KB
16.txt 163 ms 12160 KB
17.txt 161 ms 12160 KB
18.txt 158 ms 12160 KB
19.txt 125 ms 9088 KB
20.txt 124 ms 9088 KB
21.txt 124 ms 9088 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB