QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#122030#6568. Space Alignmenttacoref#WA 1ms3816kbC++17936b2023-07-09 10:10:112023-07-09 10:10:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-09 10:10:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2023-07-09 10:10:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = array<int, 2>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
using ll = long long;
using pll = pair<ll, ll>;

int N, ans = -1;
char S[1010];

int main() {
	int d = 0;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%s", S);
		int a = 0, b = 0, t = 0;
		for (t = 0; S[t]; t++) {
			if (S[t] == 's')
				b++;
			if (S[t] == 't')
				a++;
		}
		if (S[t - 1] == '}')
			d--;
		if (d <= a) {
			if (b || d < a) {
				puts("-1");
				return 0;
			}
		} else {
			if (b % (d - a) != 0 || b == 0) {
				puts("-1");
				return 0;
			}
			if (ans != -1 && ans != b / (d - a)) {
				puts("-1");
				return 0;
			}
			ans = b / (d - a);
		}
		if (S[t - 1] == '{')
			d++;
	}
	if (ans == -1)
		puts("1");
	else
		printf("%d\n", ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3388kb

input:

2
{
}

output:

1

result:

ok single line: '1'

Test #3:

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

input:

4
{
ss{
ss}
}

output:

2

result:

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