# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
930239 |
2024-02-19T07:27:58 Z |
12345678 |
Match (CEOI16_match) |
C++17 |
|
2000 ms |
1104 KB |
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5;
int n;
string s;
stack<int> st;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>s;
n=s.size();
for (auto x:s)
{
if (st.empty()||st.top()!=x) st.push(x);
else st.pop();
}
if (!st.empty()) return cout<<-1, 0;
while (!st.empty()) st.pop();
for (int i=0; i<n; i++)
{
if (st.empty()||st.top()!=s[i]) cout<<'(', st.push(s[i]);
else
{
stack<int> tmp=st;
tmp.push(s[i]);
for (int j=i+1; j<n; j++)
{
if (tmp.empty()||tmp.top()!=s[j]) tmp.push(s[j]);
else tmp.pop();
}
if (tmp.empty()) cout<<'(', st.push(s[i]);
else cout<<')', st.pop();
}
}
}
# |
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 |
# |
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 |
2 ms |
356 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
344 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 |
2 ms |
356 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
57 ms |
348 KB |
Output is correct |
9 |
Correct |
60 ms |
348 KB |
Output is correct |
10 |
Correct |
48 ms |
348 KB |
Output is correct |
11 |
Correct |
42 ms |
504 KB |
Output is correct |
12 |
Execution timed out |
2015 ms |
1104 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |