QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#387570 | #3734. Parenthesis | ucup-team1251 | WA | 2ms | 6140kb | C++17 | 1.1kb | 2024-04-12 16:50:20 | 2024-04-12 16:50:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
const int N=1e5+9;
int a[N],b[N];
vector<int>v[N];
string s ;
void solve()
{
while(cin>>n>>m)
{
cin >> s ;
s=" "+s;
int ans=0;
for(int i = 1 ; i <= n ; i++) {
a[i]=ans;
if(s[i] == '(') {
ans++;
}
else {
ans--;
}
}
ans=0;
for(int i=n;i>=1;i--)
{
b[i]=ans;
if(s[i] == '(') {
ans--;
}
else {
ans++;
}
}
while(m--) {
int x , y ;
cin >> x >>y;
if(x>y)
{
swap(x,y);
}
if(s[x]=='('&&s[y]==')'&&(a[x]==0||b[y]==0))
{
cout << "No\n" ;
}else
{
cout << "Yes\n" ;
}
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
// cin>>T;
while(T--)
{
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 6140kb
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 Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes 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 Yes Yes Yes No Yes ...
result:
wrong answer 14th words differ - expected: 'No', found: 'Yes'