# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90637 | 2018-12-23T07:47:23 Z | jangwonyoung | Match (CEOI16_match) | C++14 | 2 ms | 500 KB |
#include<iostream> #include<stack> #include<set> using namespace std; string s,b; int n; set<int>st[226]; stack<int>cut; int main(){ ios::sync_with_stdio(false); cin >> s; b=s; n=s.size(); for(int i=0; i<n ;i++) st[s[i]].insert(i); cut.push(n); for(int i=0; i<n ;i++){ if(!cut.empty() && i==cut.top()){ b[i]=')'; cut.pop(); continue; } st[s[i]].erase(i); b[i]='('; auto it=st[s[i]].upper_bound(cut.top()); if(it==st[s[i]].begin()){ cout << "-1\n"; return 0; } --it; st[s[i]].erase(it); cut.push(*it); } cout << b << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Incorrect | 2 ms | 500 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Incorrect | 2 ms | 500 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |