QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#649249#7894. Many Many HeadsLyniaWA 3ms3624kbC++233.0kb2024-10-17 22:17:262024-10-17 22:17:28

Judging History

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

  • [2024-10-17 22:17:28]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3624kb
  • [2024-10-17 22:17:26]
  • 提交

answer

///////////        
//                   //      //
//              ////////////////////
//                   //      //
//                 
///////////

//          
//          
//           //     //    ////////     /\     /////////
//           //     //   //      //          //       //
//            ////////   //      //    //    //       //
//                  //   //      //    //    //       //
//////////   ////////    //      //    //     /////////////

#pragma GCC optimize(2)
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <list>
#include <stack>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <random>
#include <numeric>
#include <functional>
//#include <Windows.h>

using namespace std;

#define fa(i,op,n) for (int i = op; i <= n; i++)
#define fb(j,op,n) for (int j = op; j >= n; j--)
#define pb push_back
#define HashMap unordered_map
#define HashSet unordered_set
#define var auto
#define all(i) i.begin(), i.end()
#define endl '\n'
#define px first
#define py second
#define DEBUG(a) cout<<a<<endl

using VI = vector<int>;
using VL = vector<long long>;
using ll = long long;
using ull = unsigned long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T1, class T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << '(' << p.first << ", " << p.second << ')';
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& ve) {
	for (T i : ve)
		out << i << ' ';
	return out;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, const map<T1, T2>& mp) {
	for (auto i : mp)
		out << i << '\n';
	return out;
}

const int INF = 0x3f3f3f3f;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
const int IINF = 0x7fffffff;
const int iinf = 0x80000000;
const ll LINF = 0x7FFFFFFFFFFFFFFF;
const ll linf = 0x8000000000000000;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

//#include "Lynia.h"

const int mod = 998244353;
const int N = 1e6 + 10;

void solve(int CASE)
{
	string a; cin >> a;
	int n = a.size();
	a = ' ' + a;
	var b = vector<int>(n + 1, -1);
	fa(i, 1, n) {
		if (a[i] == '(' or a[i] == ')')b[i] = 0;
		else b[i] = 1;
	}
	int l = 1, r = n;
	bool L = 0, R = 0;
	if (b[1] == b[2])L = 1, l = 3;
	if (b[n - 1] == b[n])R = 1, r = n - 2;
	if (L and R) {
		if (n == 2)cout << "Yes" << endl;
		else cout << "No" << endl;
		return;
	}
	fa(i, l, r) {
		int x = i, y = r - (i - l);
		if (b[x] != b[y] or b[i] == b[i - 1])break;
		if (x + 1 == y) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;
}

int main()
{
	//SetConsoleOutputCP(CP_UTF8);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int _ = 1;
	cin >> _;
	fa(i, 1, _)solve(i);
	return 0;
}

详细

Test #1:

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

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: 3556kb

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: 3ms
memory: 3624kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
N...

result:

wrong answer expected YES, found NO [3rd token]