# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59579 | 2018-07-22T12:25:16 Z | octopuses | Match (CEOI16_match) | C++17 | 3 ms | 380 KB |
//Giorgi Kldiashvili #include <bits/stdc++.h> #define ll long long #define fr first #define sc second #define M 1000000007ll using namespace std; const int N = 100020; int n; char ch[N]; string a; inline bool go(int v, stack < int > q) { q.pop(); for(int i = v; i <= n; ++ i) { if(!q.size() || a[q.top()] != a[i]) q.push(i); else q.pop(); } if(q.size()) return false; return true; } stack < int > q; int main() { scanf("%s", &ch); a = "$" + string(ch) + "$"; n = strlen(ch); for(int i = 1; i <= n; ++ i) { if(!q.size() || a[q.top()] != a[i]) q.push(i); else q.pop(); } if(q.size()) return printf("-1"), 0; while(q.size()) q.pop(); q.push(1); printf("("); for(int i = 2; i <= n; ++ i) { if(!q.size() || a[q.top()] != a[i]) q.push(i), printf("("); else { if(go(i + 1, q)) q.pop(), printf(")"); else q.push(i), printf("("); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |