QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#111011#6568. Space AlignmentTobo#WA 0ms3444kbC++201.7kb2023-06-05 13:46:522023-06-05 13:46:57

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:46:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3444kb
  • [2023-06-05 13:46:52]
  • 提交

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;
                }
            }
            else 
            {
                if (s != z)
                {
                    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: 0ms
memory: 3444kb

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

-1

result:

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