# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
74106 | zscoder | parentrises (BOI18_parentrises) | C++17 | 3 ms | 712 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
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int ans[1111111];
bool solve(string &s)
{
int n=s.length();
for(int i=0;i<n;i++) ans[i]=0;
int ptr = 0;
stack<int> S;
for(int i=0;i<n;i++)
{
if(s[i]=='(')
{
S.push(i);
}
else
{
if(!S.empty())
{
int u=S.top();
ans[i]|=1; ans[u]|=1; S.pop();
}
else
{
while(ptr<i&&(s[ptr]!='('||ans[ptr]>=3)) ptr++;
if(ptr>=i) return 0;
ans[ptr]|=2; ans[i]|=2;
}
}
}
ptr=n-1;
for(int i=n-1;i>=0;i--)
{
if(s[i]==')'||ans[i]>0) continue;
while(ptr>i&&(s[ptr]!=')'||ans[ptr]>=3)) ptr--;
ans[i]|=2; ans[ptr]|=2;
}
return 1;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int type; cin>>type;
int t; cin>>t;
while(t--)
{
if(type==1)
{
string s; cin>>s;
bool tmp = solve(s);
if(!tmp)
{
cout<<"impossible\n";
continue;
}
for(int i=0;i<s.length();i++)
{
if(ans[i]==1) cout<<"B";
else if(ans[i]==2) cout<<"R";
else cout<<"G";
}
cout<<'\n';
}
else
{
int n; cin>>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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |