QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307135#7894. Many Many HeadsSocialPandaWA 1ms3560kbC++141.4kb2024-01-18 00:46:012024-01-18 00:46:03

Judging History

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

  • [2024-01-18 00:46:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2024-01-18 00:46:01]
  • 提交

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 a=0,b=0;
    int cnt=0;


    stack<char> st;
    for(int i=0;i<(s.size());i++)
    {
        if(st.empty()) st.push(s[i]);
        else
        {
            if((s[i]=='('||s[i]==')')&&(st.top()=='('||st.top()==')')) st.pop();
            else if((s[i]=='['||s[i]==']')&&(st.top()=='['||st.top()==']')) st.pop();
            else st.push(s[i]);
        }
        if(st.empty())
        {
            cnt++;
        }
    }
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==s[i+1]&&s[i]==s[i+2])
        {
            fg=1;
        }
    }

    if(fg||cnt!=1) 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: 1ms
memory: 3548kb

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: -100
Wrong Answer
time: 0ms
memory: 3560kb

input:

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

output:

No
No

result:

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