QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706524#6568. Space Alignmentucup-team902#WA 0ms3824kbC++171.5kb2024-11-03 11:59:472024-11-03 11:59:47

Judging History

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

  • [2024-11-03 11:59:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-11-03 11:59:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
	return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int N=1005;

vector<pii> p[N];
int n;


int main(){
	#ifdef Stargazer
	freopen("1.in","r",stdin);
	#endif
	cin>>n;
	int dep=0;
	for(int j=1;j<=n;j++){
		string x;cin>>x;
		pii y;
		for(int l=x.length(),i=0;i<l;i++){
			if(x[i]=='s')y.se++;
			if(x[i]=='t')y.fi++;
			if(x[i]=='{'){
				p[dep].pb(y);
			//		cout<<j<<" "<<dep<<'\n';
				dep++;
			}
			if(x[i]=='}'){
				dep--;
				p[dep].pb(y);
			//	cout<<j<<" "<<dep<<'\n';
				
			}
		}
	}	
	int ans=-1;
	for(int i=0;i<=n;i++)if(p[i].size()){
		//cout<<i<<'\n';
		//for(pii x:p[i])cout<<x.fi<<" "<<x.se<<'\n';
		for(int j=0;j<p[i].size();j++)
		for(int k=j+1;k<p[i].size();k++){
			pii x=p[i][j],y=p[i][k];
			if(x.fi!=y.fi){
				int res=(y.se-x.se)/(x.fi-y.fi);
				if(res<=0){
					puts("-1");return 0;
				}
				if(ans>0&&ans!=res){
					puts("-1");return 0;
				}
				ans=res;
			}
			else{
				if(x.se!=y.se){
					puts("-1");return 0;
				}
			}
		}
	}
	if(ans>=0)cout<<ans<<'\n';
	else cout<<1<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

1

result:

ok single line: '1'

Test #3:

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

input:

4
{
ss{
ss}
}

output:

1

result:

ok single line: '1'

Test #4:

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

input:

4
{
tt{
tt}
}

output:

1

result:

ok single line: '1'

Test #5:

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

input:

4
{
ss{
s}
}

output:

-1

result:

ok single line: '-1'

Test #6:

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

input:

4
{
tt{
t}
}

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

4
{
tt{
s}
}

output:

-1

result:

ok single line: '-1'

Test #8:

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

input:

4
{
tt{
sss}
}

output:

1

result:

wrong answer 1st lines differ - expected: '-1', found: '1'