| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 608818 | UncoolAnon | 괄호 문자열 (CEOI16_match) | C++14 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int ok=1;
string answer,a;
void solve(int l,int r){
vector<int> occ(26);
int candidate=-1;
occ[a[l]-'a']++;
for(int i=l+1;i<=r;i++){
occ[a[i]-'a']++;
bool yes=1;
for(int j=0;j<26;++j)yes&=(occ[j]%2==0);
if(yes&&a[i]==a[l]){
candidate=i;
}
}
if(candidate==-1){
ok=0;
return ;
}
answer[l]='(';
answer[candidate]=')';
if(l+1<=candidate-1) solve(l+1,candidate-1);
if( candidate+1<=r) solve(candidate+1,r);
return;
}
int main(){
cin>>a;
for(int i=0;i<a.size();++i) answer+='#';
solve(0,a.size()-1);
if(!ok) cout<<-1;
else cout<<answer;
}
컴파일 시 표준 에러 (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... | ||||
