QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188897 | #6568. Space Alignment | ucup-team870# | WA | 0ms | 3952kb | C++14 | 1.1kb | 2023-09-26 16:18:24 | 2023-09-26 16:18:25 |
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,2){
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);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3948kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: -100
Wrong Answer
time: 0ms
memory: 3704kb
input:
100 { } { } { t{ ssssssssssssssssssssssssssssssssssss} t{ t} t{ tssssssssssssssssssssssssssssssssssss{ tssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss{ tsssssssssssssssssssssssssssssssssssst} ttssssssssssssssssssssssssssssssssssss{ ssssssssssssssssssssssssssssssssssssssssss...
output:
-1
result:
wrong answer 1st lines differ - expected: '36', found: '-1'