Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int tc;
- cin >> tc;
- while(tc--)
- {
- int n;
- cin >> n;
- vector <long long> sumaFila(n, 0);
- vector <long long> sumaColumna(n, 0);
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- long long a;
- cin >> a;
- sumaFila[i] += a;
- sumaColumna[j] += a;
- }
- }
- sort(sumaFila.begin(), sumaFila.end());
- sort(sumaColumna.begin(), sumaColumna.end());
- bool posible = true;
- for(int i=0; i<n && posible; i++)
- if(sumaFila[i] != sumaColumna[i])
- posible = false;
- if(posible)
- cout << "Possible" << endl;
- else
- cout << "Impossible" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment