Advertisement
Guest User

Untitled

a guest
Aug 13th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. char s[301488];
  4. bool is_dot[301488];
  5. int answer = 0;
  6.  
  7. void zahuyach(int whe, char wha)
  8. {
  9.     if (wha == '.' && ! is_dot[whe])
  10.     {
  11.         answer += is_dot[whe - 1];
  12.         answer += is_dot[whe + 1];
  13.     }
  14.  
  15.     if (wha != '.' && is_dot[whe])
  16.     {
  17.         answer -= is_dot[whe - 1];
  18.         answer -= is_dot[whe + 1];
  19.     }
  20.  
  21.     is_dot[whe] = (wha == '.');
  22. }
  23.  
  24. int main()
  25. {
  26.     int len, q;
  27.     scanf("%d %d", &len, &q);
  28.     scanf("%s", &s[1]);
  29.  
  30.     for (int i = 1; i <= len; ++i)
  31.     {
  32.         zahuyach(i, s[i]);
  33.     }
  34.  
  35.     while (q-- > 0)
  36.     {
  37.         int whe; char wha;
  38.         scanf("%d %c", &whe, &wha);
  39.         zahuyach(whe, wha);
  40.         printf("%d\n", answer);
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement