# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476685 | 2021-09-28T07:38:15 Z | TlenekWodoru | Match (CEOI16_match) | C++14 | 2000 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; string odp; vector<int>U; string U2; string A; void F(int v) { if(v==A.size()) { if(U.size()==0&&(odp.size()==0||odp>U2)) { odp=U2; } return; } if(U.size()>0&&A[U[U.size()-1]]==A[v]) { int kopia=U[U.size()-1]; U2.push_back(')'); U.pop_back(); F(v+1); U.push_back(kopia); U2.pop_back(); } U.push_back(v); U2.push_back('('); F(v+1); U2.pop_back(); U.pop_back(); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>A; F(0); if(odp.size()==0){cout<<"-1"<<endl;} else{cout<<odp<<endl;} return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Execution timed out | 2090 ms | 332 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Execution timed out | 2090 ms | 332 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |