QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#111005#6568. Space AlignmentTobo#WA 2ms3444kbC++201.1kb2023-06-05 13:29:052023-06-05 13:29:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-05 13:29:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3444kb
  • [2023-06-05 13:29:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define N 200005

void solve()
{
    int n;
    cin >> n;
    vector<string> a(n + 1);
    vector<int> b(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i].back() == '{')
            b[i] = 1;
        else
            b[i] = -1;
        b[i] += b[i - 1];
    }
    for (int j = 0; j <= 1e3; j++)
    {
        bool is = 1;
        for (int i = 2; i < n; i++)
        {
            int s = 0, t = 0;
            for (char c : a[i])
            {
                if (c == 's')
                    s++;
                else if (c == 't')
                    t++;
            }
            int z = j * b[i];
            if (s > z || (t > 0 && (z - s) % t))
            {
                is = 0;
                break;
            }
        }
        if (is)
        {
            cout << j << '\n';
            return;
        }
    }
    cout << -1;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3444kb

input:

2
{
}

output:

0

result:

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