QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593398#6568. Space Alignmentticking_away#WA 0ms3816kbC++171.2kb2024-09-27 13:49:202024-09-27 13:49:21

Judging History

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

  • [2024-09-27 13:49:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-09-27 13:49:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e2 + 7;

int n, s[MXN], t[MXN], lft[MXN];

int check(int k) {
    int num = 0;
    for(int i=0, dpt=0; i<n; ++i) {
        if(!lft[i]) --dpt;
        if(t[i]) {
            int tmp = (k*dpt-s[i]);
            if(tmp<0||tmp%t[i]!=0) return 0;
            if(num&&tmp/t[i]!=num) return 0;
            num = tmp/t[i];
        } else if(k*dpt!=s[i]) return 0;
        if(lft[i]) ++dpt;
    }
    return num;
}

void solve() {
    for(int i=1, v; i<=1000; ++i) {
        if((v=check(i))) {
            cout << v;
            return;
        }
    }
    cout << "-1";
}

void pre() {
    cin >> n;
    string inp;
    for(int i=0; i<n; ++i) {
        cin >> inp;
        for(char ch:inp) {
            switch(ch) {
                case 's': ++s[i]; break;
                case 't': ++t[i]; break;
                case '{': lft[i]=1; break;
                default: lft[i] = 0;
            }
        }
    }
}

int t_=1;
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    // cin >> t_;
}

int main() {
    init();
    for(int i=1; i<=t_; ++i) {
        pre(); solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

2
{
}

output:

-1

result:

wrong answer 1st lines differ - expected: '1', found: '-1'