QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623047 | #7894. Many Many Heads | WaO_o# | WA | 0ms | 3588kb | C++20 | 1.2kb | 2024-10-09 09:47:53 | 2024-10-09 09:47:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deg( x ) cout<<""#x"="<<x<<endl
#define endl '\n'
#define pll pair<int,int>
#define fr frist
#define se second
const int N=100+10;
void solve( ){
string s;
cin>>s;
int n=s.size();
for( auto &x:s ){
if( x==')' ) x='(';
if( x==']' ) x='[';
}
if( n==2 ){
cout<<"Yes"<<endl;
}
else{
if( n==4 ){
bool ok=false;
for( int i=1; i<n; i++ ){
if( s[ i ]!=s[ i-1 ] ) ok=true;
}
if( ok ) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else{
bool ok=true;
for( int i=1; i<n/2; i++ ){
if( s[ i ]==s[ i-1 ] ) ok=false;
}
if( s[ n/2 ]!=s[ ( n/2 )-1 ] ) ok=false;
for( int i=n/2+1; i<n; i++ ){
if( s[ i ]==s[ i-1 ] ) ok=false;
}
if( ok ) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
}
signed main() {
ios::sync_with_stdio( 0 );
cin.tie( 0 ); cout.tie( 0 );
int T=1;
cin>>T;
while( T-- ){
solve( );
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3444kb
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: 3588kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]