QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398486#7894. Many Many HeadsxiaoleWA 4ms3796kbC++23799b2024-04-25 13:42:532024-04-25 13:42:54

Judging History

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

  • [2024-04-25 13:42:54]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3796kb
  • [2024-04-25 13:42:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 2e5+9;const ll MOD = 1e9 + 7;
void solve(){
   string s;cin>>s;
   ll n=s.size();
   s=" "+s;
   for (ll i = 1; i <= n; i++)
   {
		if(s[i]=='(' or s[i]==')') s[i]='1';
		else s[i]='2';
   }
   ll cnt=0;
   stack<char> st;st.push(s[1]);
   for (ll i = 2; i <= n; i++)
   {
		if(st.size() and st.top()==s[i]) st.pop();
		else st.push(s[i]);
		if(st.size()==0) 
			cnt++;
		
		
   }
   if(cnt>2 or (cnt==2 and s[1]==s[n])) cout<<"No\n";
   else{
	
   cout<<"Yes\n";
   }
}
int main(){
	ios;ll _=1;cin>>_;
	while (_--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

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: 4ms
memory: 3796kb

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

result:

wrong answer expected NO, found YES [45th token]