QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153164#6568. Space Alignmentqzez#WA 1ms3528kbC++141.2kb2023-08-29 15:14:142023-08-29 15:14:14

Judging History

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

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

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];
bool chk(int ans){
	int t1,t2,dep;
	tie(t1,t2,dep)=o[1];
	int tmp=t1+t2*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);
		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;
}

詳細信息

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

0

result:

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