QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#188902 | #6568. Space Alignment | ucup-team870# | AC ✓ | 0ms | 3952kb | C++14 | 1.1kb | 2023-09-26 16:19:57 | 2023-09-26 16:19:57 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,l,r) for(int i=l; i<=r; i++)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
char ch[1005];
int a[105],s[105],t[105];
int main(){
int n; cin>>n;
For(i,1,n){
scanf("%s",ch+1); int l=1;
while(ch[l]!='}'&&ch[l]!='{'){
if (ch[l]=='s') ++s[i];
if (ch[l]=='t') ++t[i];
++l;
}
if (ch[l]=='{') a[i]=0; else a[i]=1;
//cout<<a[i]<<' '<<s[i]<<' '<<t[i]<<endl;
}
if (s[1]||t[1]||s[n]||t[n]) printf("-1"),exit(0);
if (n==2) printf("1\n"),exit(0);
For(tt,1,1005){
int c=0,l=0; bool flag=0;
For(i,2,n){
if (!a[i]) ++c; //else --c;
//cout<<'#'<<' '<<i<<' '<<s[i]<<' '<<t[i]<<endl;
if (!l&&c==1) {
l=s[i]+t[i]*tt;
if (!l) printf("-1"),exit(0);
}
if (c*l!=s[i]+t[i]*tt) {flag=1; break;}
//cout<<'#'<<tt<<' '<<i<<' '<<c<<' '<<l<<endl;
if (a[i]) --c;
}
if (!flag) printf("%d\n",tt),exit(0);
}
printf("-1"),exit(0);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3948kb
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: 3896kb
input:
100 { t{ tssssssssssssssssssss{ ttssssssssssssssssssss{ tsssssssssssssssssssstt{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{ ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...
output:
20
result:
ok single line: '20'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
4 { t{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
999
result:
ok single line: '999'