QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361971#8509. Expanding STACKS!ucup-team052#WA 0ms3864kbC++23940b2024-03-23 13:47:572024-03-23 13:47:58

Judging History

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

  • [2024-03-23 13:47:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-03-23 13:47:57]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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