| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 30818 | zscoder | Match (CEOI16_match) | C++14 | 2000 ms | 31392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<int,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
bool err;
string s;
void solve(int l, int r)
{
if(l>r) return ;
stack<char> S;
string ans;
int idx=-1;
if(s[l]==s[r])
{
solve(l+1,r-1);
if(err) return ;
s[l]='('; s[r]=')';
return ;
}
for(int i = r; i > l; i--)
{
if(!S.empty()&&S.top()==s[i])
{
S.pop();
}
else
{
S.push(s[i]);
}
if(s[l]==s[i-1]&&S.empty())
{
idx=i;
break;
}
}
if(idx<=l)
{
err=true;
return ;
}
solve(l+1,idx-2);
solve(idx,r);
s[l]='('; s[idx-1]=')';
}
char a[100011];
int main()
{
scanf("%s", a);
int idx=0;
while(a[idx]!='\0')
{
s+=a[idx];
idx++;
}
solve(0,int(s.length())-1);
if(err) cout<<-1<<'\n';
else cout<<s<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
