Advertisement
vlatkovski

Kvadrat

Oct 2nd, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n; cin >> n;
  6.     vector<vector<int>> k;
  7.     int ax, ay;
  8.     for (int y = 0; y < n; ++y) {
  9.         vector<int> v;
  10.         for (int x = 0; x < n; ++x) {
  11.             int b; cin >> b;
  12.             if (b == -1) {
  13.                 ax = x; ay = y;
  14.             }
  15.             v.push_back(b);
  16.         }
  17.         k.push_back(v);
  18.     }
  19.     int sum = 0;
  20.     for (int y = 0; y < n; ++y) {
  21.         if (y == ay) {
  22.             continue;
  23.         }
  24.         for (int x = 0; x < n; ++x) {
  25.             sum += k[y][x];
  26.         }
  27.         break;
  28.     }
  29.     int sum_m_a = 0;
  30.     for (int x = 0; x < n; ++x) {
  31.         sum_m_a += k[ay][x];
  32.     }
  33.     sum_m_a++; //a=-1
  34.     int a = sum-sum_m_a;
  35.     cout << a << endl;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement