Submission #10612829


Source Code Expand

// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	string s;cin >> s;
	deque<char> dq;
	forn(i, s.size())dq.pb(s[i]);
	bool rev = false;
	int q;cin >> q;
	while(q--){
		int t;cin >> t;
		if(t == 1)rev ^= 1;
		else{
			int f;cin >> f;
			char c;cin >> c;
			if(rev){
				if(f == 1)dq.pb(c);
				else dq.push_front(c);
			}
			else {
				if(f == 1)dq.push_front(c);
				else dq.pb(c);
			}
		}
	}
	string ans;
	while(!dq.empty()){
		ans += dq.front();
		dq.pop_front();
	}
	if(rev)reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Submission Info

Submission Time
Task D - String Formation
User vO_Ov
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1515 Byte
Status AC
Exec Time 28 ms
Memory 1368 KiB

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 KiB
02.txt AC 1 ms 256 KiB
03.txt AC 1 ms 256 KiB
04.txt AC 1 ms 256 KiB
05.txt AC 1 ms 256 KiB
06.txt AC 1 ms 256 KiB
07.txt AC 1 ms 256 KiB
08.txt AC 1 ms 256 KiB
09.txt AC 1 ms 256 KiB
10.txt AC 1 ms 256 KiB
11.txt AC 28 ms 1360 KiB
12.txt AC 28 ms 1364 KiB
13.txt AC 28 ms 1364 KiB
14.txt AC 27 ms 1364 KiB
15.txt AC 27 ms 1368 KiB
16.txt AC 27 ms 1364 KiB
17.txt AC 27 ms 1368 KiB
18.txt AC 27 ms 1364 KiB
19.txt AC 24 ms 1236 KiB
20.txt AC 24 ms 1236 KiB
21.txt AC 24 ms 1236 KiB
s1.txt AC 1 ms 256 KiB
s2.txt AC 1 ms 256 KiB
s3.txt AC 1 ms 256 KiB