QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#307135 | #7894. Many Many Heads | SocialPanda | WA | 1ms | 3560kb | C++14 | 1.4kb | 2024-01-18 00:46:01 | 2024-01-18 00:46:03 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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]