QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367148#8509. Expanding STACKS!ucup-team266#WA 1ms3800kbC++201.7kb2024-03-25 19:26:312024-03-25 19:26:31

Judging History

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

  • [2024-03-25 19:26:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3800kb
  • [2024-03-25 19:26:31]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int INF=1e18;
int n;
int L[1005],R[1005];
vector <int> g[1005];
int col[1005];
void dfs(int u,int c)
{
	col[u]=c;
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(col[v]==-1) dfs(v,c^1);
		else if(col[v]!=(c^1))
		{
			cout<<"*\n";
			exit(0);
		}
	}
}
void solve()
{
	cin>>n;
	for(int i=1;i<=2*n;i++)
	{
		string s;
		cin>>s;
		int x=0;
		for(int j=1;j<s.size();j++) x=10*x+s[j]-'0';
		if(s[0]=='+') L[x]=i;
		else R[x]=i;
	}
	for(int i=1;i<=n;i++) if(L[i]>R[i])
	{
		cout<<"*\n";
		return;
	}
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) if(min(R[i],R[j])-max(L[i],L[j])!=0&&min(R[i],R[j])-max(L[i],L[j])!=min(R[i]-L[i],R[j]-L[j])) g[i].pb(j),g[j].pb(i);
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;i++) if(col[i]==-1) dfs(i,-1);
	for(int i=1;i<=n;i++) cout<<(col[i]==1?"G":"S");
	cout<<"\n";
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3796kb

input:

2
+2 +1 -1 -2

output:

SS

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3800kb

input:

2
+1 +2 -1 -2

output:

SS

result:

wrong answer client leaving is not the top of its stack