Submission #10631829


Source Code Expand

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

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());
    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))
            s=get<0>(v)+s;
        else
            s=s+get<0>(v);
    }
    cout<<s<<endl;
    
    return 0;
}

Submission Info

Submission Time
Task D - String Formation
User NB29979
Language C++14 (GCC 5.4.1)
Score 0
Code Size 780 Byte
Status
Exec Time 2104 ms
Memory 14040 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
× 3
× 16
× 8
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 2104 ms 13972 KB
12.txt 2104 ms 14028 KB
13.txt 2104 ms 14040 KB
14.txt 2104 ms 12840 KB
15.txt 2104 ms 12880 KB
16.txt 2104 ms 12832 KB
17.txt 2104 ms 12908 KB
18.txt 2104 ms 12892 KB
19.txt 1714 ms 9856 KB
20.txt 1713 ms 9844 KB
21.txt 1712 ms 9804 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB