QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207749#6568. Space AlignmentFreeuni1#WA 0ms7572kbC++231.2kb2023-10-08 19:51:322023-10-08 19:51:32

Judging History

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

  • [2023-10-08 19:51:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7572kb
  • [2023-10-08 19:51:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define ARRS ((ll)(2e6 + 100))
#define MOD ((ll)998244353)
#define MAX ((ll)(1e9 + 100))
#define EP ((double)(1e-9))

ll cs[ARRS];
ll ct[ARRS];
ll dir[ARRS];

int main() {

	ll n;
	cin>>n;
	for(int i=0; i<n; i++){
		string s;
		cin>>s;
		for(int j=0; j<s.size(); j++){
			if(s[j]=='s')cs[i]++;
			if(s[j]=='t')ct[i]++;
		}
		if(s[s.size()-1]=='{') dir[i]=1;
		else dir[i]=-1;
	}
	for(int wt=1; wt<=1; wt++){
		ll ws = -1;
		ll cd = 0;
		ll good=1;

		for(int i=0; i<n; i++){
			if(dir[i]==-1)cd--;
			ll d = cd;
			// cout<<cd<<endl;
			if(!d&&(ct[i]+cs[i])>0) {
				good=0;
				break;
			}
			if(ct[i]%wt!=0){
				good=0;
				break;
			}
			d-=ct[i]/wt;
			if(!d&&cs[i]>0) {
				good=0;
				break;
			}
			if(d && ws==-1){
				if(cs[i]%d!=0){
					good=0;
					break;
				}
				ws = cs[i]/d;
			}
			if(cs[i]%ws){
				good=0;
				break;
			}
			d-=cs[i]/ws;
			if(d!=0) {
				good=0;
				break;
			}
			if(dir[i]==1)cd++;
		}
		// cout<<"g"<<good<<endl;
		if(good){
			if(ws%wt==0){
				cout<<ws/wt<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

-1

result:

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