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