# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1118052 | 2024-11-24T19:39:47 Z | vjudge1 | 괄호 문자열 (CEOI16_match) | C++17 | 2000 ms | 592 KB |
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define endl "\n" #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; vector<ll>val; vector<vector<ll>>edge; vector<ll>check; ll k,c=0; int main() { AI //freopen(“kangaroo.in”, “r”, stdin); // freopen(“kangaroo.out”, “w”, stdout); ll i,j,k,n; string a; cin>>a; n=a.size(); stack<char>s; for(i=0;i<n;i++) { if(s.size() and s.top()==a[i]) s.pop(); else s.push(a[i]); } if(s.size()) { cout<<-1<<endl; return 0; } string z=""; for(i=0;i<n;i++) { stack<char>st; for(j=0;j<i;j++) { if(z[j]=='(') st.push(a[j]); else st.pop(); } st.push(a[i]); for(j=i+1;j<n;j++) { if(st.size() and st.top()==a[j]) st.pop(); else st.push(a[j]); } if(st.size()) z+=')'; else z+='('; } cout<<z<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 2 ms | 336 KB | Output is correct |
5 | Correct | 3 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 336 KB | Output is correct |
7 | Correct | 8 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 2 ms | 336 KB | Output is correct |
5 | Correct | 3 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 336 KB | Output is correct |
7 | Correct | 8 ms | 336 KB | Output is correct |
8 | Correct | 69 ms | 480 KB | Output is correct |
9 | Correct | 98 ms | 508 KB | Output is correct |
10 | Correct | 102 ms | 336 KB | Output is correct |
11 | Correct | 106 ms | 336 KB | Output is correct |
12 | Execution timed out | 2045 ms | 592 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |