QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387571#3734. ParenthesiswanyurukongWA 2ms6140kbC++171.1kb2024-04-12 16:50:242024-04-12 16:50:24

Judging History

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

  • [2024-04-12 16:50:24]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6140kb
  • [2024-04-12 16:50:24]
  • 提交

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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

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'