Submission #12898808


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














string S;
int idx = 0;
//---------------------------------------------------------------------------------------------------
string parse() {
	if (S[idx] == '(') {
		idx++;
		string res = parse();
		idx++;

		string ser = res;
		reverse(all(ser));
		return res + ser + parse();
	}
	else if ('a' <= S[idx] && S[idx] <= 'z') {
		string res = S.substr(idx, 1);
		idx++;
		res += parse();
		return res;
	}
	return "";
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	S += "#";
	cout << parse() << endl;
}





Submission Info

Submission Time
Task J - Parse
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 6
Code Size 1897 Byte
Status AC
Exec Time 5 ms
Memory 3788 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 6 / 6
Status
AC × 3
AC × 19
Set Name Test Cases
Sample Sample_01.txt, Sample_02.txt, Sample_03.txt
All Sample_01.txt, Sample_02.txt, Sample_03.txt, almostkakko_01.txt, almostkakko_02.txt, almostkakko_03.txt, hand_01.txt, hand_02.txt, hand_03.txt, iti_01.txt, nokakko_01.txt, rand_large_01.txt, rand_large_02.txt, rand_large_03.txt, rand_large_04.txt, rand_large_05.txt, rand_small_01.txt, rand_small_02.txt, rand_small_03.txt
Case Name Status Exec Time Memory
Sample_01.txt AC 5 ms 3524 KB
Sample_02.txt AC 2 ms 3584 KB
Sample_03.txt AC 2 ms 3628 KB
almostkakko_01.txt AC 2 ms 3664 KB
almostkakko_02.txt AC 2 ms 3496 KB
almostkakko_03.txt AC 2 ms 3616 KB
hand_01.txt AC 2 ms 3684 KB
hand_02.txt AC 2 ms 3600 KB
hand_03.txt AC 2 ms 3604 KB
iti_01.txt AC 2 ms 3460 KB
nokakko_01.txt AC 2 ms 3788 KB
rand_large_01.txt AC 2 ms 3512 KB
rand_large_02.txt AC 2 ms 3592 KB
rand_large_03.txt AC 2 ms 3592 KB
rand_large_04.txt AC 2 ms 3628 KB
rand_large_05.txt AC 2 ms 3640 KB
rand_small_01.txt AC 2 ms 3584 KB
rand_small_02.txt AC 2 ms 3564 KB
rand_small_03.txt AC 2 ms 3524 KB