Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- int n, m, l, r;
- cin >> n >>m;
- string a;
- cin >> a;
- for (int i = 0; i < m; i++)
- {
- cin >> l >> r;
- for (int j = l - 1; j < r; j++)
- {
- if (a[j] == '1') a[j] = '0';
- else if (a[j] == '0') a[j] = '1';
- }
- }
- int counter = 0;
- int tempcounter = 0;
- for (int i = 0; i <= n; i++)
- {
- if (a[i] != a[i+1]) tempcounter++;
- else if (a[i] == a[i+1] && counter < tempcounter)
- {
- counter = tempcounter;
- }
- else tempcounter = 0;
- }
- cout << counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement