General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
188037578 Practice:
DaiRuiChen007
1593G - 16 C++14 (GCC 6-32) Accepted 139 ms 8816 KB 2023-01-05 16:23:01 2023-01-05 16:23:01
→ Source
// LUOGU_RID: 98778152
#include<bits/stdc++.h> 
using namespace std;
const int MAXN=1e6+1;
char str[MAXN];
int sum[MAXN][2];
inline void solve() {
	scanf("%s",str+1);
	int n=strlen(str+1);
	for(int i=1;i<=n;++i) {
		sum[i][0]=sum[i-1][0],sum[i][1]=sum[i-1][1];
		if(str[i]=='['||str[i]==']') ++sum[i][i%2];
	}
	int q;
	scanf("%d",&q);
	while(q--) {
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",abs((sum[r][0]-sum[l-1][0])-(sum[r][1]-sum[l-1][1])));
	}
}
signed main() {
	int T;
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details