# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117704 |
2024-11-24T07:38:54 Z |
vjudge1 |
Match (CEOI16_match) |
C++17 |
|
1 ms |
336 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
string s;
cin>>s;
int n = s.size();
for (int i = (1<<n) - 1; i >= 0; i--){
deque<int> de;
int pr = 0, can = 1;
for (int j = 0; j < n; j++){
int val = i & (1<<j);
if (val != 0) val = -1;
else val = 1;
pr += val;
if (pr < 0){
can = 0;
break;
}
}
for (int j = 0; j < n; j++){
int val = i & (1<<j);
if (val != 0) val = -1;
else val = 1;
pr += val;
if (pr < 0){
can = 0;
break;
}
}
for (int j = 0; j < n; j++){
if (!can) break;
int val = i & (1<<j);
if (val == 0){
de.push_back(j);
}
else{
if (s[de.back()] != s[j]){
can = 0;
break;
}
de.pop_back();
}
}
if (de.size() != 0) can = 0;
if (can){
for (int j = 0; j < n; j++){
if (!can) break;
int val = i & (1<<j);
if (val == 0){
cout<<'(';
}
else{
cout<<')';
}
}
return 0;
}
}
cout<<-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |