QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#367149#8509. Expanding STACKS!ucup-team266#WA 1ms3800kbC++201.7kb2024-03-25 19:27:132024-03-25 19:27:14

Judging History

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

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

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);//,cout<<i<<" "<<j<<"\n";
	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;
}

详细

Test #1:

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

input:

2
+2 +1 -1 -2

output:

GG

result:

ok correct

Test #2:

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

input:

2
+1 +2 -1 -2

output:

GS

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

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

output:

*

result:

ok correct

Test #4:

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

input:

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

output:

*

result:

wrong answer team and jury output doesn't agree on whether there's an assignment