QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#122023 | #6568. Space Alignment | tacoref# | WA | 1ms | 3804kb | C++17 | 926b | 2023-07-09 09:56:50 | 2023-07-09 09:56:54 |
Judging History
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) {
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: 3576kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3804kb
input:
4 { ss{ ss} }
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'