QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#387562 | #3734. Parenthesis | ucup-team1251 | WA | 0ms | 5668kb | C++17 | 1.6kb | 2024-04-12 16:46:22 | 2024-04-12 16:46:22 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <bitset>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define lowbit(x) x&(-x)
#define pi 3.14159265358
#define lc k<<1;
#define rc k<<1|1
#define ppb push_back
#define mod 1000000007
#define fori(i,l,r) for(int i=l;i<=r;i++)
#define forj(j,l,r) for(int j=l;j<=r;j++)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair <int, int> pll;
const int N = 2e6 + 10;
const int P = 131;
ll cnt = 0;
ll t, n, m, ans = 0;
struct peo{
int l, r;
}arr[N], brr[N];
void ac(){
while (cin >> n >> m){
string s;
cin >> s;
s = " " + s;
int s1 = 0, s2 = 0;
arr[n + 1].l = 0, arr[n + 1].r = 0;
brr[n + 1].l = 0, brr[n + 1].r = 0;
for (int i = 1; i <= n; i++){
if (s[i] == '(')s1++;
else s2++;
arr[i].l = s1, arr[i].r = s2;
}s1 = 0, s2 = 0;
for (int i = n; i >= 1; i--){
if (s[i] == '(')s1++;
else s2++;
brr[i].l = s1, brr[i].r = s2;
}int a, b;
for (int i = 1; i <= m; i++){
cin >> a >> b;
if (s[a] == '('&&s[b] == ')'){
arr[a].l--, arr[a].r++;
brr[b].l++, brr[b].r--;
if (arr[a].l - arr[a].r + brr[b].l - brr[b].r != 0 || ((arr[a - 1].l - arr[a - 1].r == 0) && (brr[b + 1].l - brr[b + 1].r == 0)))cout << "No\n";
else cout << "Yes\n";
arr[a].l++, arr[a].r--;
brr[b].l--, brr[b].r++;
}
else{
cout << "Yes\n";
}
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie();
cout.tie();
t = 1;
while (t--){
ac();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5668kb
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 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 No Yes Yes Yes No Yes Yes Yes No Yes No 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 No Yes Yes Yes Yes Yes No Yes Yes Yes ...
result:
wrong answer 3rd words differ - expected: 'No', found: 'Yes'