/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 136ms 3.258 MiB
#4 Accepted 662ms 7.766 MiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 149ms 2.273 MiB
#7 Accepted 138ms 2.223 MiB
#8 Accepted 27ms 1.102 MiB
#9 Time Exceeded ≥1100ms ≥12.664 MiB
#10 Time Exceeded ≥1099ms ≥12.535 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
   string s ; cin >> s ;
   deque < char > dq ;
   for(auto it : s) dq.pb(it) ;
   int q ; cin >> q ;
   bool rev = 0 ;
   while(q--){
    int ty , f ; cin >> ty ;
    char ch ;
    if(ty == 1) rev ^= 1 ;
    else {
        cin >> f >> ch ;
        if(f == 1 ){
            if(rev) dq.pb(ch) ;
            else dq.push_front(ch) ;
        }
        else {
            if(rev) dq.push_front(ch) ;
            else dq.pb(ch) ;
        }
    }
   }
   if(rev){
    for(int i = dq.size() - 1 ; i >= 0 ; i--) cout << dq[i] ;
   }
   else for(auto it : dq) cout << it ;
   cout << "\n" ;
}
int main()
{
     __Heart__
    // WRITE("output.txt") ;
     //READ("input.txt") ;
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-14 14:32:44
Judged At
2024-08-14 14:32:44
Judged By
Score
80
Total Time
≥1100ms
Peak Memory
≥12.664 MiB