QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276264 | #7894. Many Many Heads | Godwang | WA | 4ms | 3484kb | C++14 | 2.8kb | 2023-12-05 19:01:07 | 2023-12-05 19:01:09 |
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]='[';
}
}
//
bool flag=0;
//cout<<s<<endl;
int flagyuan=0,flagfang=0,idyuan=0,idfang=0;
//0 len-1
rep(i,0,len-2)// meiju liangge
{
if(i<=len-3)
{
if(s[i]==s[i+1]&&s[i]==s[i+2])
{
flag=1;
break;
}
}
if(s[i]==s[i+1])
{
if(s[i]=='(')
{
if(flagyuan==0)
{
flagyuan=1;
idyuan=i;
}
else
{
if(i-idyuan>=2)
{
flag=1;
break;
}
}
}
else
{
if(flagfang==0)
{
flagfang=1;
idfang=i;
}
else
{
if(i-idfang>=2)
{
flag=1;
break;
}
}
}
}
}
ttt:
if(flag)
{
cout<<"No\n";
}
else
{
cout<<"Yes\n";
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3400kb
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: 1ms
memory: 3480kb
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: 3484kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes No No Yes No No Yes No No No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No...
result:
wrong answer expected YES, found NO [7th token]