Submission #63913622


Source Code Expand

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define desktop "C:\\Users\\MPC\\Desktop\\"
#define IOS ios :: sync_with_stdio (false),cin.tie (0),cout.tie (0)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> PII;
const int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};
template <typename T1,typename T2> bool tomax (T1 &x,T2 y) {
	if (y > x) return x = y,true;
	return false;
}
template <typename T1,typename T2> bool tomin (T1 &x,T2 y) {
	if (y < x) return x = y,true;
	return false;
}
LL power (LL a,LL b,LL p) {
	LL ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ans;
}
int fastio = (IOS,0);
#define endl '\n'
#define puts(s) cout << (s) << endl
const int N = 400010;
int n;
PII a[N];
int b[N];
int stk[N],top;
bool tmp;
char ans[N];
void mian () {
	cin >> n;
	for (int i = 1;i <= n * 2;i++) cin >> a[i].x,a[i].y = i;
	sort (a + 1,a + n * 2 + 1,greater <PII> ());
	for (int i = 1;i <= n;i++) b[a[i].y] = 1;
	for (int i = 1;i <= 2 * n;i++) {
		if (!top) {
			tmp = b[i];
			stk[++top] = i;
			continue;
		}
		if (b[i] == tmp) stk[++top] = i;
		else {
			ans[stk[top]] = '(',ans[i] = ')';
			top--;
		}
	}
	for (int i = 1;i <= 2 * n;i++) cout << ans[i];
	cout << endl;
}
int main () {
	int T = 1;
	// cin >> T;
	while (T--) mian ();
	return 0;
}

Submission Info

Submission Time
Task D - Bracket Score 2
User incra
Language C++ 17 (gcc 12.2)
Score 600
Code Size 1475 Byte
Status AC
Exec Time 61 ms
Memory 8532 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_duplicates_00.txt, random_duplicates_01.txt, random_duplicates_02.txt, random_duplicates_03.txt, sample_01.txt, sample_02.txt, special_00.txt, special_01.txt, special_02.txt, special_03.txt, special_04.txt, special_05.txt, special_06.txt, special_07.txt
Case Name Status Exec Time Memory
handmade_00.txt AC 1 ms 3420 KiB
handmade_01.txt AC 1 ms 3452 KiB
random_00.txt AC 54 ms 8480 KiB
random_01.txt AC 54 ms 8384 KiB
random_02.txt AC 55 ms 8520 KiB
random_03.txt AC 55 ms 8504 KiB
random_04.txt AC 47 ms 7864 KiB
random_05.txt AC 37 ms 6900 KiB
random_06.txt AC 36 ms 6724 KiB
random_07.txt AC 34 ms 6760 KiB
random_duplicates_00.txt AC 61 ms 8508 KiB
random_duplicates_01.txt AC 58 ms 8452 KiB
random_duplicates_02.txt AC 46 ms 7168 KiB
random_duplicates_03.txt AC 43 ms 7136 KiB
sample_01.txt AC 1 ms 3384 KiB
sample_02.txt AC 1 ms 3396 KiB
special_00.txt AC 21 ms 8532 KiB
special_01.txt AC 31 ms 8472 KiB
special_02.txt AC 36 ms 8460 KiB
special_03.txt AC 33 ms 8380 KiB
special_04.txt AC 26 ms 8400 KiB
special_05.txt AC 54 ms 8492 KiB
special_06.txt AC 28 ms 8464 KiB
special_07.txt AC 29 ms 8524 KiB