QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#338501#6568. Space AlignmentAestivateAC ✓1ms3832kbC++201.5kb2024-02-25 23:15:532024-02-25 23:15:53

Judging History

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

  • [2024-02-25 23:15:53]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3832kb
  • [2024-02-25 23:15:53]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long 
#define pb push_back
#define F first 
#define S second 


vector<string>all[105];
int ans[105];
void solve(){
    int n;
    cin>>n;
    int now=0, mx=0;
    while(n--){
        string a;
        cin>>a;
        if(a[a.size()-1]=='}') now--, all[now].pb(a), mx=max(mx, now);
        else all[now].pb(a), mx=max(mx, now), now++;
    }

    for(int j=1;j<=1000;j++){
        // cerr<<j<<"\n";
        bool oo=1;
        for(int i=1;i<=mx;i++){
            ans[i]=0;int pre=-1;
            bool ok=1;
            for(auto t:all[i]){
                int p=0;
                for(int ii=0;ii<t.size()-1;ii++){
                    if(t[ii]=='s'){
                        p++;
                    }
                    else {
                        p+=j;
                    }
                }
                if(pre==-1) ans[i]=p, pre=p;
                else{
                    if(pre!=p) {
                        ok=0;
                        break;
                    }
                }
            }
            if(!ok) {
                oo=0;
                break;
            }
            if(ans[i]-ans[i-1]!=ans[1]) {
                oo=0;
                break;
            }
        }
        if(oo){
            cout<<j<<"\n";
            return;
        }
    }
    cout<<"-1\n";
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3784kb

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

2
{
}

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

4
{
ss{
ss}
}

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

4
{
tt{
tt}
}

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

4
{
ss{
s}
}

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

4
{
tt{
t}
}

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

4
{
tt{
s}
}

output:

-1

result:

ok single line: '-1'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

4
{
tt{
sss}
}

output:

-1

result:

ok single line: '-1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

4
{
tt{
ssss}
}

output:

2

result:

ok single line: '2'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

6
{
}
{
tt{
ssss}
}

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3596kb

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: 1ms
memory: 3572kb

input:

100
{
t{
tssssssssssssssssssss{
ttssssssssssssssssssss{
tsssssssssssssssssssstt{
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{
ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...

output:

20

result:

ok single line: '20'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

4
{
t{
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...

output:

999

result:

ok single line: '999'