# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867554 | 2023-10-28T16:17:11 Z | 42kangaroo | parentrises (BOI18_parentrises) | C++17 | 1 ms | 600 KB |
// // Created by 42kangaroo on 28/10/2023. // #include "bits/stdc++.h" using namespace std; #define int long long array<char,3> col{'G', 'R', 'B'}; signed main() { int p, t; cin >> p >> t; while (t--) { if (p == 1) { string s; cin >> s; bool pos = true; vector<int> co(s.size(),0); deque<int> closeInd; vector<int> openInd; int act = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == '(') { ++act; } else { closeInd.push_back(i); --act; if (act < 0) { if (closeInd.size() < 2) { cout << "impossible\n"; pos = false; break; } else { co[closeInd.front()] = 2; closeInd.pop_front(); co[closeInd.front()] = 1; closeInd.pop_front(); ++act; } } } } act = 0; for(int i = s.size() - 1; i >= 0; --i) { if (s[i] == '(') { openInd.push_back(i); --act; if (act < 0) { if (openInd.empty()) { cout << "impossible\n"; pos = false; break; } else { co[openInd.back()] = 2; openInd.pop_back(); ++act; } } } else if (co[i] < 2){ ++act; } } assert(!pos || act == 0); openInd.clear(); for(int i = s.size() - 1; i >= 0; --i) { if (s[i] == '(' && (co[i] == 0 || co[i] == 2)) { if (co[i] == 0) { openInd.push_back(i); } --act; if (act < 0) { if (openInd.empty()) { cout << "impossible\n"; pos = false; break; } else { co[openInd.back()] = 1; openInd.pop_back(); ++act; } } } else if (s[i] == ')' && (co[i] == 0 || co[i] == 2)){ ++act; } } assert(!pos || act == 0); if (pos) { for (auto e: co) { cout << col[e]; } cout << "\n"; } /*if (pos) { for (int i = 0; i < s.size(); ++i) { if (co[i] != 2) cout << s[i]; } cout << "\n"; for (int i = 0; i < s.size(); ++i) { if (co[i] != 1) cout << s[i]; } cout << "\n"; }*/ } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 600 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Extra information in the output file |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Incorrect | 0 ms | 344 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Incorrect | 0 ms | 344 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |