Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define pb push_back
- #define p_b pop_back
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin >> t;
- while(t--){
- int n, m;
- cin >> n >> m;
- string s;
- cin >> s;
- for(int i = 0; i < m; i++){
- int x = 0;
- set<int> s1;
- s1.insert(0);
- int a, b;
- cin >> a >> b;
- for(int j = 0; j < a-1; j++){
- if(s[j] == '+'){
- x++;
- } else if(s[j] == '-'){
- x--;
- }
- s1.insert(x);
- }
- for(int j = b; j < s.length(); j++){
- if(s[j] == '+'){
- x++;
- } else if(s[j] == '-'){
- x--;
- }
- s1.insert(x);
- }
- cout << s1.size() << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement