QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#111010#6568. Space AlignmentTobo#WA 3ms3468kbC++201.5kb2023-06-05 13:45:082023-06-05 13:45:10

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:45:10]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3468kb
  • [2023-06-05 13:45:08]
  • 提交

answer

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

void solve()
{
    int n;
    cin >> n;
    vector<array<int, 3>> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        string ss;
        cin >> ss;
        int s = 0, t = 0, z = 0;
        for (char c : ss)
        {
            if (c == 's')
                s++;
            else if (c == 't')
                t++;
            else if (c == '{')
                z++;
            else
                z--;
        }
        a[i] = {s, t, z};
    }
    for (int j = 1; j <= 1e6; j++)
    {
        bool is = 1;
        int tab = -1, cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            auto [s, t, o] = a[i];
            if (o == -1)
                cnt -= j;
            int z = 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 (o == 1)
                cnt += j;
        }
        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();
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3464kb

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

-1

result:

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