Advertisement
tepyotin2

Coin Flipping 1/10

Dec 9th, 2023
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     ios_base::sync_with_stdio(0), cin.tie(0);
  7.     // freopen("flipping.in", "r", stdin);
  8.     int n;
  9.     cin >> n;
  10.     int face[n][n];
  11.     for(int i=0; i<n; i++){
  12.         for(int j=0; j<n; j++){
  13.             cin >> face[i][j];
  14.         }
  15.     }
  16.     int count = 1;
  17.     for(int i=n-1; i>=0; i--){
  18.         for(int j=n-1; j>=0; j--){
  19.             if(face[i][j] == 1){
  20.                 count++;
  21.                 for(int row = 0; row<n; row++){
  22.                     for(int col = 0; col<n; col++){
  23.                         face[row][col] = 1-face[row][col];
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.     }
  29.     cout << count << '\n';
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement