QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#348999#6568. Space AlignmentjanY#WA 1ms3588kbC++171.9kb2024-03-09 22:52:062024-03-09 22:52:06

Judging History

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

  • [2024-03-09 22:52:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-03-09 22:52:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long

void solve(){
    long long d, n;
    cin >> n;
    vector<string> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    vector<int> dep(n);
    int run = -1;
    for (int i = 0; i < n; i++){
        if (c[i].back() == '{'){
            if (i == 0) run++;
            else {
                if (c[i-1].back() == '{') run++;
            }
        } else {
            if (c[i-1].back() == '}'){
                run--;
            }
        }
        c.pop_back();
        dep[i] = run;
        //cout << run << " ";
    }
    vector<int> scnt(n);
    vector<int> tcnt(n);
    for (int i = 0; i < n; i++){
        for (auto &z : c[i]){
            if (z == 's') scnt[i]++;
            if (z == 't') tcnt[i]++;
        }
    }


    for (int i = 0; i < 40005; i++){
        int fmlt = -1;
        bool isgood = true;
        for (int j = 0; j < n; j++){
            int thiz = scnt[j] + tcnt[j]*i;
            if (dep[j] == 0){
                if (thiz != 0){
                    isgood = false;
                    break;
                }
            } else {
                if (thiz == 0){
                    isgood = false;
                    break;
                }
                if (fmlt == -1){
                    if (thiz%dep[j] == 0){
                         fmlt = thiz/dep[j];
                    } else {
                        isgood = false;
                        break;
                    }
                } else {
                    if (fmlt*dep[j] != thiz){
                        isgood = false;
                        break;
                    }
                }
            }
        }
        if (isgood){
            cout << i;
            return;
        }

    }
    cout << -1;

}

int main(){

    int t = 1;
    //cin >> t;
    for (int i = 0; i < t; i++) solve();

    return 0;
}


详细

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3588kb

input:

2
{
}

output:

0

result:

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