QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153166#6568. Space Alignmentqzez#WA 1ms3780kbC++141.2kb2023-08-29 15:16:222023-08-29 15:16:22

Judging History

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

  • [2023-08-29 15:16:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2023-08-29 15:16:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
const int N=1e2+10,M=1e3+10;
int n;
vector<tuple<int,int,int> >o;
char s[M];
int p1,p2;
bool chk(int ans){
	int tmp=p1+p2*ans;
	for(auto t:o){
		int t1,t2,dep;
		tie(t1,t2,dep)=t;
		if(t1+t2*ans!=1ll*dep*tmp)return 0;
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	if(n==2)return cout<<0<<endl,0;
	for(int i=1,x=0;i<=n;i++){
		scanf("%s",s+1);
		int len=strlen(s+1);
		int t1=0,t2=0;
		for(int j=1;j<len;j++){
			t1+=s[j]=='s',t2+=s[j]=='t';
		}
		if(s[len]=='}')x--;
		// debug(t1,t2,x);
		if(x==1)p1=t1,p2=t2;
		o.push_back({t1,t2,x});
		if(s[len]=='{')x++;
	}
	for(int ans=1;ans<=10000;ans++){
		if(chk(ans))return cout<<ans<<endl,0;
	}
	cout<<-1<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

0

result:

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