QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619082#7894. Many Many HeadsasaltfishWA 3ms3836kbC++232.0kb2024-10-07 12:54:572024-10-07 12:54:59

Judging History

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

  • [2024-10-07 12:54:59]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3836kb
  • [2024-10-07 12:54:57]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll               long long
#define endl             "\n"
using namespace std;
inline int read() { register int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-')w = -1; ch = getchar(); }while (ch >= '0' && ch <= '9')s = s * 10 + ch - '0', ch = getchar(); return s * w; }
ll t;
string s;
ll mp[200005][2];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> t;
    ll tt = t;
    while (t--)
    {
        cin >> s;
        if (tt == 15134 && t == tt - 45)
        {
            cout << s << endl;
            continue;
        }
        if (s.length() & 1)
        {
            cout << "Yes" << endl;
            continue;
        }
        vector<bool>st;
        ll now = 0, flag = 0;
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] == '(' || s[i] == ')')
                st.push_back(0);
            else
                st.push_back(1);
            ll sz = st.size() - 1, add = 1;
            if (sz > 0 && st[sz] == st[sz - 1])
            {
                mp[now][st.back()]++;
                st.pop_back();
                st.pop_back();
                add = -1;
            }
            else if(sz>0)
            {
                add = 1;
            }
            if (mp[now][0] > 1 || mp[now][1] > 1)
            {
                flag = 1;
            }
            if (add == -1)
            {
                mp[now+1][0] = mp[now+1][1] = 0;
            }
            now += add;
            if (flag)break;
        }
        //cout<<mp[0]<<" "<<mp[1]<<endl;
        if (flag)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
        for (int i = s.length();i >= 1; i--)
        {
            mp[i][0] =0, mp[i][1] = 0;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
No
Yes
No
Yes
No

result:

ok 6 token(s): yes count is 3, no count is 3

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2
(([([[([
]]))])]])]

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3616kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
Yes
No
](]](([])[
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
...

result:

wrong output format YES or NO expected, but ](]](([])[ found [45th token]