QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354640 | #6568. Space Alignment | Delay_for_five_minutes# | WA | 1ms | 3672kb | C++14 | 1.0kb | 2024-03-15 19:53:31 | 2024-03-15 19:53:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=53;
int n,m,b[N];
pii a[N];
string s;
bool chk(int k){
int t=-1,x;
for(int i=1;i<=n;++i){
x=k*a[i].second+a[i].first;
if(b[i]==0)continue;
if(x%b[i])return 0;
if(t>0&&x/b[i]!=t)return 0;
t=x/b[i];
}
return 1;
}
int main(){
cin>>n;
for(int i=1,d=0,o=-1;i<=n;++i){
cin>>s;
int x=0,y=0;
for(int i=0;s[i]=='s'||s[i]=='t';++i){
x+=s[i]=='s';
y+=s[i]=='t';
}
if(s.back()=='{'){
if(o==0)++d;
o=0;
}
else if(s.back()=='}'){
if(o==1)--d;
o=1;
}
a[i]={x,y};
b[i]=d;
if(b[i]==0&&a[i]!=pii(0,0)){
cout<<"-1\n";
return 0;
}
}
for(int k=1;k<=1000;++k)if(chk(k)){
cout<<k<<'\n';
return 0;
}
cout<<"-1\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: -100
Wrong Answer
time: 1ms
memory: 3664kb
input:
100 { } { } { t{ ssssssssssssssssssssssssssssssssssss} t{ t} t{ tssssssssssssssssssssssssssssssssssss{ tssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss{ tsssssssssssssssssssssssssssssssssssst} ttssssssssssssssssssssssssssssssssssss{ ssssssssssssssssssssssssssssssssssssssssss...
output:
1
result:
wrong answer 1st lines differ - expected: '36', found: '1'