Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int d, n;
- cin >> d;
- for (int i = 0; i< d ; i++) {
- cin >> n;
- int tab[n][n];
- for (int j = 0; j< n; j++) {
- for (int k = 0; k< n; k++) {
- cin >> tab[j][k];
- }
- }
- int j =0, k =0;
- while((j < n) && (k < n)) {
- if (tab[j][k]==1) {
- j++;
- } else {
- k++;
- }
- }
- if (j == n) {
- cout << (k+1) << "\n";
- } else {
- cout << (j+1) << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement