QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#111007#6568. Space AlignmentTobo#WA 2ms3512kbC++201.4kb2023-06-05 13:37:542023-06-05 13:37:58

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:37:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3512kb
  • [2023-06-05 13:37:54]
  • 提交

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);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int j = 1; j <= 1e3; j++)
    {
        bool is = 1;
        int tab = -1, cnt = 0;
        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++;
            }
            if (a[i].back() == '{')
                cnt++;
            int z = j * cnt;
            if (s > z || (t > 0 && (z - s) % t))
            {
                is = 0;
                break;
            }
            if (t > 0)
            {
                if (tab == -1)
                    tab = (z - s) / t;
                else if (tab != (z - s) / t)
                {
                    is = 0;
                    break;
                }
            }
            if (a[i].back() == '}')
                cnt--;
        }
        if (is)
        {
            cout << tab << '\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: 2ms
memory: 3512kb

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

-1

result:

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