# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64036 | Just_Solve_The_Problem | parentrises (BOI18_parentrises) | C++11 | 1067 ms | 568 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
void solve1() {
string s;
cin >> s;
int pw = 1;
for (int i = 0; i < sz(s); i++) {
pw *= 3;
}
int a[14];
bool fl = 0;
for (int mask = 0; mask < pw; mask++) {
int musk = mask;
fl = 1;
for (int i = sz(s) - 1; i >= 0; i--) {
int bit = musk % 3;
musk /= 3;
a[i] = bit;
}
int b1, b2;
b1 = b2 = 0;
for (int i = 0; i < sz(s); i++) {
if (a[i] < 2) {
if (s[i] == '(') b1++;
else b1--;
if (b1 < 0) fl = 0;
}
if (a[i] > 0) {
if (s[i] == '(') b2++;
else b2--;
if (b2 < 0) fl = 0;
}
}
fl &= (b1 == 0 && b2 == 0);
if (fl) {
// cout << b1 << ' ' << b2 << endl;
break;
}
}
if (!fl) {
puts("impossible");
} else {
for (int i = 0; i < sz(s); i++) {
if (a[i] == 0) printf("R");
if (a[i] == 1) printf("G");
if (a[i] == 2) printf("B");
}
puts("");
}
}
main() {
int p;
scanf("%d", &p);
if (p == 1) {
int test;
scanf("%d", &test);
while (test--)
solve1();
} else {
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |