QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#275837 | #7894. Many Many Heads | Godwang | WA | 0ms | 3620kb | C++14 | 2.3kb | 2023-12-05 09:19:18 | 2023-12-05 09:19:19 |
Judging History
answer
#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pb emplace_back
#define pii pair<int, int>
#define ll long long
#define endl '\n'
int dir[4][2] =
{
{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
ll fastpow(ll a, ll n, ll mod)
{
ll ans = 1;
a %= mod;
while (n)
{
if (n & 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
n >>= 1;
}
return ans;
}
const int N = 1e2 + 10;
const double eps = 1e-8;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("ain.txt", "r", stdin);freopen("aout.txt", "w", stdout);
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
int len=s.size();
//
rep(i,0,len-1)
{
if(s[i]==')')
{
s[i]='(';
}
else if(s[i]==']')
{
s[i]='[';
}
}
//
//cout<<s<<endl;
bool flag=0;
//0 len-1
rep(i,0,len-2)// meiju liangge
{
if(s[i]==s[i+1])
{
int leftt=i,rightt=i+1;
while(0<=leftt-1 &&rightt+1<=len-1)
{
if(s[leftt-1]==s[rightt+1])
{
if(s[leftt-1]==s[leftt])
{
flag=1;
goto ttt;
}
leftt--;
rightt++;
}
else
{
break;
}
}
//
//cout<<leftt<<endl;
//
}
}
ttt:
if(flag)
{
cout<<"No\n";
}
else
{
cout<<"Yes\n";
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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:
Yes Yes
result:
wrong answer expected NO, found YES [2nd token]