QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#599953 | #6568. Space Alignment | Forever_Young# | WA | 0ms | 3948kb | C++14 | 1.1kb | 2024-09-29 13:35:02 | 2024-09-29 13:35:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
char s[1005];
vector<pair<int,int>> v[105];
int main(){
scanf("%d",&n);
int dep=0;
int max_dep=0;
for (int i=0;i<n;i++){
scanf("%s",s);
int len=strlen(s);
if (s[len-1]=='}') dep--;
max_dep=max(max_dep,dep);
int ns=0,nt=0;
for (int j=0;j<len-1;j++)
if (s[j]=='s') ns++; else nt++;
// printf("%d %d %d\n",dep,ns,nt);
v[dep].push_back({ns,nt});
if (s[len-1]=='{') dep++;
}
for (int w=1;w<=1000;w++){
bool flag=true;
int t2s = -1;
for (int i=0;i<=max_dep&&flag;i++)
for (auto x:v[i]){
if (x.second>0&&t2s==-1){
t2s=(w*i-x.first)/x.second;
}
if (x.first+t2s*x.second!=w*i){
flag=false;
break;
}
}
if (flag){
printf("%d\n",t2s);
return 0;
}
}
printf("-1");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3948kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'