QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593494 | #6568. Space Alignment | ticking_away# | AC ✓ | 0ms | 3804kb | C++17 | 1.2kb | 2024-09-27 14:22:55 | 2024-09-27 14:22:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e2 + 7;
int n, s[MXN], t[MXN], lft[MXN];
bool fg;
bool check(int k) {
int num = 0;
for(int i=0, dpt=0; i<n; ++i) {
if(!lft[i]) --dpt;
if(dpt>0) {
num = s[i]+k*t[i];
break;
}
if(lft[i]) ++dpt;
}
for(int i=0, dpt=0; i<n; ++i) {
if(!lft[i]) --dpt;
if(s[i]+k*t[i]!=num*dpt) return 0;
if(lft[i]) ++dpt;
}
return 1;
}
void solve() {
for(int i=1, v; i<=1000; ++i) {
if(check(i)) {
cout << i;
return;
}
}
cout << "-1";
}
void pre() {
cin >> n;
string inp;
for(int i=0; i<n; ++i) {
cin >> inp;
for(char ch:inp) {
switch(ch) {
case 's': ++s[i]; break;
case 't': ++t[i]; fg = 1; break;
case '{': lft[i]=1; break;
default: lft[i] = 0;
}
}
}
}
int t_=1;
void init() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
// cin >> t_;
}
int main() {
init();
for(int i=1; i<=t_; ++i) {
pre(); solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
100 { } { } { t{ ssssssssssssssssssssssssssssssssssss} t{ t} t{ tssssssssssssssssssssssssssssssssssss{ tssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss{ tsssssssssssssssssssssssssssssssssssst} ttssssssssssssssssssssssssssssssssssss{ ssssssssssssssssssssssssssssssssssssssssss...
output:
36
result:
ok single line: '36'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
100 { t{ tssssssssssssssssssss{ ttssssssssssssssssssss{ tsssssssssssssssssssstt{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{ ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...
output:
20
result:
ok single line: '20'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
4 { t{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
999
result:
ok single line: '999'