Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int m, n, k, i, j, t, x, y, c, c1;
  9.     vector <vector<char> >grid;
  10.     cin >> t;
  11.     while(t--){
  12.         cin >> m >> n >> k;
  13.         for(i = 0; i < m; i++){
  14.             for(j = 0; j < n; j++){
  15.                 grid[i][j] = '.';
  16.             }
  17.         }
  18.         for(i = 0; i < k; i++){
  19.             cin >> x >> y;
  20.             grid[x-1][y-1] = '*';
  21.         }
  22.         c = 0;
  23.         c1 = 0;
  24.         for(i = 0; i < m; i++){
  25.             j = 0;
  26.             while(j < n){
  27.                 while(grid[i][j] == '.'){
  28.                     c1++;
  29.                     j++;
  30.                 }
  31.                 if(c1 > 1)c++;
  32.                 j++;
  33.             }
  34.         }
  35.         cout << c;
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement