QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599953#6568. Space AlignmentForever_Young#WA 0ms3948kbC++141.1kb2024-09-29 13:35:022024-09-29 13:35:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 13:35:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3948kb
  • [2024-09-29 13:35:02]
  • 提交

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");
}

详细

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'