QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412993#6568. Space AlignmentLspeed#WA 1ms3476kbC++141.5kb2024-05-16 23:20:252024-05-16 23:20:27

Judging History

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

  • [2024-05-16 23:20:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3476kb
  • [2024-05-16 23:20:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

int main() {
	// your code goes here
	int n; cin>>n;
	pii k[n];
	int d[n];
	int depth = 0;
	for(int i=0;i<n;i++) {
		string s; cin>>s;
// 		cout<<i<<s<<endl;
		int a = 0, b = 0;
// 		cout<<s.size()<<'\n';
		for(int j=0;j<s.size()-1;j++) {
// 			cout<<j<<'\n';
			if(s[j] == 's')
				a++;
			else
				b++;
		}
// 		cout<<i<<s<<"WTF\n";
		d[i] = depth;
		k[i] = {a,b};
		if(s[s.size()-1] == '{')
			depth++;
		else {
		    d[i]--;
			depth--;
		}
// 		cout<<i<<' '<<d[i]<<' '<<depth<<'\n';
	}
// 	cout<<"YES\n";
	int can = -10;
	bool pass = false;
	for(int i=0;i<n;i++) {
		for(int j=0;j<i;j++) {
		    if(d[i] == -1 || d[j] == -1)
		        continue;
			int aa = k[i].first * d[j], bb = k[i].second *d[j], cc = k[j].first*d[i], dd = k[j].second*d[i];
// 			cout<<i<<' '<<j<<' '<<aa<<' '<<bb<<' '<<cc<<' '<<dd<<' '<<can<<'\n';
			if(bb == dd) {
				if(aa == cc) {
					continue; 
				}
				else {
					can = -1;
				}
			}
			else if(aa == cc) {
			    if(bb == dd)
			        continue;
			    else
			        can = 0;
			}
			else {
				if((abs(cc-aa))%(abs(bb-dd)) != 0) {
					can = -1;
					continue;
				}
				int new_can = (cc-aa)/(bb-dd);
				// cout<<new_can<<endl;
				if(can == -10) {
					can = new_can;
				}
				else if(can != new_can) {
					can = -1;
				}
			}
		}
	}
	if(can == -10) can = 0;
	cout<<can<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

0

result:

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