QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361940#8509. Expanding STACKS!ucup-team052#WA 0ms3788kbC++23849b2024-03-23 13:40:482024-03-23 13:40:48

Judging History

你现在查看的是最新测评结果

  • [2024-03-23 13:40:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-03-23 13:40:48]
  • 提交

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 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)printf("%c",fd(i)==fd(1)?'G':'S');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3748kb

input:

2
+2 +1 -1 -2

output:

GS

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

2
+1 +2 -1 -2

output:

GS

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

3
+1 +2 +3 -1 -2 -3

output:

*

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

10
+3 -3 +4 -4 +6 +2 -2 -6 +7 -7 +5 -5 +10 +1 +9 +8 -8 -9 -1 -10

output:

GSSSSSSSSS

result:

ok correct

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3752kb

input:

10
+8 -8 +2 +10 -2 -10 +7 -7 +1 -1 +6 -6 +5 +3 +4 +9 -9 -4 -3 -5

output:

GSSSSSSSSS

result:

wrong answer client leaving is not the top of its stack