QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#361971 | #8509. Expanding STACKS! | ucup-team052# | WA | 0ms | 3864kb | C++23 | 940b | 2024-03-23 13:47:57 | 2024-03-23 13:47:58 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#endif
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
#define pb push_back
using namespace std;
const int N=2005;
int n,a[N],L[N],R[N],fa[N];
int vis[N];
int fd(int x){return fa[x]==x?x:fa[x]=fd(fa[x]);}
int main(){
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
cin>>n;
rep(i,1,n*2)fa[i]=i;
rep(i,1,n*2){
cin>>a[i];
if(a[i]>0){
L[a[i]]=i;
}else{
R[-a[i]]=i;
}
}
rep(i,1,n)rep(j,1,n)if(i!=j){
if(L[i]<L[j]&&L[j]<R[i]&&R[i]<R[j]){
fa[fd(j)]=fd(i+n);
fa[fd(j+n)]=fd(i);
}
}
rep(i,1,n){
if(fd(i)==fd(i+n)){
puts("*");
exit(0);
}
}
rep(i,1,n)if(!vis[fd(i)]&&!vis[fd(i+n)]){
vis[fd(i)]=vis[fd(i+n)]=i;
printf("%c",fd(i)==fd(vis[fd(i)])?'G':'S');
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
2 +2 +1 -1 -2
output:
GG
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3736kb
input:
2 +1 +2 -1 -2
output:
G
result:
wrong answer solution is not a string of length N