QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307137#7894. Many Many HeadsSocialPandaWA 5ms3584kbC++141.2kb2024-01-18 00:56:242024-01-18 00:56:24

Judging History

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

  • [2024-01-18 00:56:24]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3584kb
  • [2024-01-18 00:56:24]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
//#define int long long
//#define LL long long
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int,int>
#define MII map<int,int>
#define MSI map<string,int>
#define MAXN 0x3f3f3f3f
#define MINN -0x3f3f3f3f
#define Gheap priority_queue<int>
#define Lheap priority_queue<int,vector<int>,greater<int>>
using namespace std;
//const int N=1e6+100;
//int e[N],w[M],ne[M],h[M],idx;

void solve()
{
    string s;
    cin>>s;
    int fg=0;
    int cnt=0;
    vector<int> v;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]==')'||s[i]=='(') v.eb(1);
        else v.eb(0);
    }

    for(int i=0;i<s.size()-1;i++)
    {
        if(v[i]==v[i+1]&&v[i]==v[i+2])
        {
            fg=1;
            break;
        }
        if(v[i]==v[i+1]) cnt++;
    }

    if(fg||cnt>2) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

详细

Test #1:

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

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: 3480kb

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: 5ms
memory: 3532kb

input:

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

output:

No
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
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
No
No
No
No
No
No
No
No
No
No
No...

result:

wrong answer expected YES, found NO [1st token]