QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#387393 | #3734. Parenthesis | ucup-team1251 | WA | 8ms | 3736kb | C++17 | 1.2kb | 2024-04-12 14:31:45 | 2024-04-12 14:31:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char C[N];
int a[N], b[N];
int main()
{
int m, n;
while (cin >> m >> n)
{
cin >> (C + 1);
for (int i = 1; i <= m; i++)
{
a[i] = a[i - 1], b[i] = b[i - 1];
if (C[i] == '(')
a[i] = a[i] + 1;
else
b[i] = b[i] + 1;
}
while (n--)
{
int l, r;
cin >> l >> r;
if (l > r)
swap(l, r);
if (C[l] == C[r] || C[l] == ')')
cout << "Yes\n";
else if (l == 1 || r == m)
cout << "No\n";
else
{
if (r - l == 1)
{
if (a[l - 1] == b[l - 1])
cout << "No\n";
else
cout << "Yes\n";
}
else if (a[l] - 1 >= b[l] + 1 && a[l + 1] - 1 >= b[l + 1] + 1 && (a[m] - a[r - 1] + 1) <= (b[m] - b[r - 1] - 1) && (a[m] - a[r - 2]) <= (b[m] - b[r - 2]))
cout << "Yes\n";
else
cout << "No\n";
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
10 100 (()())()() 1 2 4 2 3 1 2 3 4 1 3 2 5 4 2 4 1 5 4 3 3 5 3 1 5 3 2 5 4 5 3 5 4 2 5 4 3 5 2 3 4 1 2 4 2 5 2 5 3 4 4 1 5 1 1 2 5 1 2 3 4 2 1 3 2 3 2 1 4 1 1 5 5 1 3 4 3 4 1 5 1 4 1 3 4 1 3 5 1 2 3 1 1 2 2 3 5 3 2 1 3 5 1 5 5 4 2 1 1 4 4 5 4 1 4 1 2 4 5 3 5 4 3 2 3 5 5 4 3 5 1 4 5 1 1 5 3 2 3 4 2 ...
output:
Yes Yes No Yes Yes Yes Yes Yes No Yes Yes No Yes No Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes No Yes No Yes Yes No Yes Yes Yes No No Yes Yes No Yes No Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes No No Yes Yes No Yes No Y...
result:
ok 100 tokens
Test #2:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
10 100 (()(())()) 4 3 1 3 5 1 5 2 3 4 5 2 5 4 5 2 5 2 4 2 3 4 1 3 4 2 1 5 1 5 2 5 4 1 3 4 3 1 5 2 5 4 4 5 4 2 4 3 5 1 1 2 4 5 4 3 1 5 4 2 3 4 1 5 2 3 3 4 4 2 2 5 5 2 3 2 5 2 1 4 3 1 5 4 3 4 5 1 5 4 4 2 3 2 2 5 2 1 1 2 3 5 5 2 3 5 5 2 2 3 4 3 1 5 3 5 1 4 1 2 2 5 5 1 1 3 2 1 4 5 1 2 3 2 3 1 2 5 5 4 3 ...
output:
Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes Yes No Yes Yes No No No Yes Ye...
result:
ok 100 tokens
Test #3:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
10 100 (()()()()) 1 2 4 5 2 5 2 4 3 1 5 1 3 2 3 2 3 1 5 2 3 4 3 5 5 4 2 5 4 2 1 5 3 1 3 2 4 1 5 2 4 5 5 3 2 3 2 5 4 1 5 1 3 4 2 3 2 4 2 4 1 5 5 4 1 5 4 5 4 1 3 1 2 1 5 2 2 3 1 2 5 2 4 1 3 5 4 5 3 4 4 5 3 1 5 3 4 2 2 1 2 5 4 2 1 5 1 2 3 2 5 1 1 4 5 1 2 4 3 1 1 2 5 3 5 4 4 1 4 5 3 1 5 1 3 5 5 4 5 4 2 ...
output:
Yes Yes No Yes No No Yes Yes No No Yes Yes Yes No Yes No No Yes Yes No Yes Yes Yes No Yes No Yes Yes Yes Yes No Yes No Yes Yes No Yes No Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes No Yes No Yes No Yes Yes Yes Yes Yes No No Yes Yes Yes No No Yes Yes Yes No No Yes Yes No No Yes Ye...
result:
ok 100 tokens
Test #4:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
10 100 ()()()()() 2 1 5 3 4 3 3 4 1 5 3 5 3 2 4 1 2 1 4 3 2 3 3 5 5 4 1 3 2 3 1 3 2 1 3 2 3 2 4 1 1 5 1 5 4 3 3 4 3 4 1 2 4 5 3 4 5 4 4 1 4 2 4 5 3 4 5 2 3 1 2 1 3 1 1 4 1 3 4 2 5 1 2 1 1 3 4 5 2 4 2 3 5 4 1 2 3 2 1 2 3 5 1 5 1 2 1 5 5 4 4 3 2 4 3 1 4 2 5 1 5 1 3 2 2 1 1 5 3 2 1 3 1 3 1 4 4 1 5 3 4 ...
output:
No Yes No No Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes No No No No Yes No Yes No Yes Yes No Yes Yes No Yes No Yes Yes Yes No Yes Yes Yes Yes Yes No Yes No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No No Yes No Yes No Yes Yes No No Yes No No Yes Yes No ...
result:
ok 100 tokens
Test #5:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
10 100 ()(()()()) 2 1 4 2 2 4 2 3 1 5 3 2 4 2 4 1 2 5 4 5 2 3 5 3 1 5 4 1 5 2 1 5 2 5 3 4 5 2 4 2 3 1 1 4 5 2 4 2 4 3 4 2 5 3 5 2 2 4 2 5 1 4 5 1 2 3 3 5 5 3 3 5 2 4 5 1 3 5 1 2 2 3 1 3 3 2 2 5 4 5 1 3 5 4 1 2 3 4 3 2 1 5 4 2 4 1 3 4 5 4 1 4 3 5 1 2 2 3 1 3 5 3 1 5 5 2 4 2 5 1 4 5 4 1 5 4 4 3 2 4 2 ...
output:
No Yes Yes Yes No Yes Yes Yes Yes Yes Yes No No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No No No Yes No No No Yes Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes Yes Yes Yes No No Yes Yes No No Yes Yes No Yes Yes Yes Yes Yes Yes No No Yes Yes No Yes No No Yes Yes Y...
result:
ok 100 tokens
Test #6:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
10 100 (()()()()) 4 2 1 4 4 1 3 2 2 4 4 5 4 1 5 4 5 2 4 1 2 5 1 2 3 5 4 3 1 5 3 1 1 5 4 5 5 2 5 2 1 3 5 3 5 4 3 1 5 3 1 2 1 5 4 3 4 3 5 1 5 4 4 5 4 1 3 4 5 4 4 3 3 2 4 2 4 3 1 3 1 2 1 3 3 4 1 3 3 2 4 1 3 1 2 5 3 5 4 5 5 4 3 4 4 2 3 2 2 1 1 2 3 2 4 1 1 5 5 4 5 1 2 1 3 1 5 2 1 2 4 2 5 4 5 3 3 1 2 5 4 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes No Yes No Yes Yes Yes No No No Yes No No No Yes Yes No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No No Yes Yes Yes Yes No No Yes Yes No No No Yes Yes Yes Yes No No Yes...
result:
ok 100 tokens
Test #7:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
10 100 ((()())()) 1 5 4 3 1 2 2 1 1 2 3 5 1 3 2 1 2 4 4 2 4 3 5 3 4 2 1 4 5 4 2 4 3 5 1 3 1 2 5 4 3 2 5 2 5 4 4 1 4 1 3 2 5 1 5 1 1 2 4 2 2 1 4 2 4 3 2 4 5 4 5 4 1 5 3 1 2 3 2 4 4 2 1 2 2 4 2 3 3 2 1 4 5 2 4 2 5 2 4 2 1 2 2 1 4 1 4 1 1 4 4 5 5 1 5 1 5 2 4 1 2 3 3 1 1 2 5 1 3 1 1 2 4 2 3 4 4 1 2 4 1 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes No No No Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Y...
result:
ok 100 tokens
Test #8:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
10 100 ()()()()() 2 1 5 2 5 1 3 5 4 3 4 5 2 3 5 4 5 1 4 2 3 2 2 1 2 3 5 2 4 3 3 4 3 5 5 4 2 1 2 3 5 4 2 5 1 3 3 5 5 4 5 4 4 5 3 4 5 4 4 5 4 3 1 4 2 4 3 1 1 5 4 3 1 3 1 3 2 4 1 2 3 2 2 1 1 5 5 4 3 4 5 3 1 5 3 4 3 1 5 3 3 5 3 1 5 4 1 3 4 3 4 5 3 2 5 4 1 4 5 3 5 2 4 5 1 5 5 4 2 1 1 3 1 4 5 2 3 4 5 4 1 ...
output:
No Yes Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes No No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes No No Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes Yes No Yes Yes Yes Yes Yes No Yes No Yes No Yes No Yes Yes Yes Yes Yes Yes Yes Yes No N...
result:
ok 100 tokens
Test #9:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
10 100 ()()()()() 5 3 4 5 2 3 3 5 1 3 1 3 2 1 1 2 3 1 4 5 1 4 1 4 1 2 4 1 3 2 3 5 5 4 5 2 4 5 4 3 5 3 4 1 1 5 4 2 4 1 2 3 1 3 4 2 4 1 3 2 5 4 1 3 5 3 2 1 1 5 4 3 2 4 5 3 3 1 2 5 5 4 1 2 4 1 2 5 4 2 4 2 5 1 3 4 5 1 4 1 2 4 3 5 2 5 1 5 4 1 2 4 2 4 4 2 3 2 4 2 3 5 2 3 5 1 3 1 3 4 1 3 3 1 3 1 2 3 4 5 1 ...
output:
Yes Yes Yes Yes Yes Yes No No Yes Yes No No No No Yes Yes Yes Yes Yes No Yes No Yes Yes No Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes Yes Yes Yes Yes No No Yes Yes Yes Yes No Yes No Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes No Yes No No Yes No Yes Yes No Yes Yes...
result:
ok 100 tokens
Test #10:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
10 100 ()(()()()) 1 3 3 1 2 5 1 2 3 5 3 4 4 3 3 2 1 5 3 1 5 2 3 1 1 2 3 1 2 1 3 4 4 3 4 2 5 3 5 4 5 2 2 1 5 2 5 1 4 1 2 1 3 1 5 2 3 5 4 3 3 1 1 2 5 1 2 1 3 5 2 1 1 2 2 3 5 4 4 3 3 4 3 5 5 3 3 1 4 1 4 5 1 3 1 5 1 3 1 4 2 4 2 5 5 3 4 5 4 5 4 3 3 4 2 1 1 4 5 2 2 4 4 3 2 4 1 3 3 1 4 2 5 1 3 4 2 4 3 2 1 ...
output:
Yes Yes Yes No No Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes Yes No Yes Yes No Yes No Yes No Yes Yes No Yes Yes No No No No No No Yes Yes Yes Yes No No Yes Yes Yes Yes No Yes Yes Yes Yes No Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes No Yes Yes Yes No Y...
result:
ok 100 tokens
Test #11:
score: 0
Accepted
time: 3ms
memory: 3708kb
input:
1000 10000 ((((()()()(())(((()())()()()()()()()())()()(()()())()()()()()()((()()()()()(())())))(()()(()()(()))(()()()()()()())()()()()()()()))()(())()()()()()()()()()()()()(()()()()()()))()()(()()())()(())(()()()())(())()()(()()()()()()()()())(()((())())()()()())()()()()(()()()()()()(()()()()()(((()...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ...
result:
ok 10000 tokens
Test #12:
score: 0
Accepted
time: 8ms
memory: 3712kb
input:
1000 10000 (((((()(())(())()()()(()(()()()()()))((())((()))()()()()()()())()()()()()()()(())(()(())())(()())(())()()(())()()()()((()(()()())()())()()()()()())()((()()()(()()())()()())))(()())(((((())((())())(())())()())))((())()()()()()))(())()(())(())()()()()())(()()()()()()()()()()()()()()(((()()(...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ...
result:
ok 10000 tokens
Test #13:
score: -100
Wrong Answer
time: 4ms
memory: 3708kb
input:
1000 10000 ()()()()()()()()(())(())()()(()()()())()()()()()(()()(()())())(())((()()(()()()()())()()()(())))((((((()()()()()(()()()()()()()()()())()()()(())()()())))()((())(()(()()()))((()(()(())))()()))))((()()((()()))(())()(((()()(())()())))())(()()(())()()())()()()()(()()()()())()()(())((()())())(...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes ...
result:
wrong answer 21st words differ - expected: 'No', found: 'Yes'