QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128217 | #6568. Space Alignment | installb# | WA | 1ms | 3616kb | C++14 | 996b | 2023-07-20 18:22:47 | 2023-07-20 18:22:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool is_prime(ll x){
for(ll i = 2;i * i <= x;i ++){
if(x % i == 0) return 0;
}
return 1;
}
char s[1005];
int solve(){
int n;
int ans = -1;
cin >> n;
for(int ind = 0,i = 1;i <= n;i ++){
cin >> s;
int len = strlen(s);
if(s[len - 1] == '}') ind -= 2;
int a = 0,b = -ind;
for(int j = 0;j < len - 1;j ++){
if(s[j] == 's') b ++;
if(s[j] == 't') a ++;
}
if(a == 0 && b != 0) return -1;
if(a > 0){
if(b >= 0) return -1;
if(b % a != 0) return -1;
int cur = -b / a;
if(ans != -1 && ans != cur) return -1;
ans = cur;
}
if(s[len - 1] == '{') ind += 2;
}
if(ans == -1) ans = 1;
return ans;
}
int main(){
ios::sync_with_stdio(false);
cout << solve() << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3356kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3452kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3404kb
input:
4 { tt{ ssss} }
output:
-1
result:
wrong answer 1st lines differ - expected: '2', found: '-1'