1365A - Matrix Game - CodeForces Solution


games greedy implementation *1100

Please click on ads to support us..

Python Code:

num_inp=lambda: int(input())
arr_inp=lambda: list(map(int,input().split()))
sp_inp=lambda: map(int,input().split())
str_inp=lambda:input()
I=input
for _ in[0]*int(I()):
 n,m=map(int,I().split());k=l=0
 for _ in[0]*n:x=int(I()[::2],2);k+=x<1;l|=x
 print('VAisvheiks h'[min(k,m-bin(l).count('1'))%2::2])

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while (t--)
    {
        /* code */
        set<int>r,c;
        int n,m;
        cin >> n>>m;
        for(int i=0;i<n;i++){
            for (int j =0; j < m; j++)
            {
                /* code */
                int x;
                cin >> x;
                if(x==1){
                    r.insert(i);
                    c.insert(j);
                }

            }
            
        }
        int ans = min(n-r.size(),m-c.size());
        if(ans%2==0){
            cout <<"Vivek"<<endl;
        }
        else{
            cout << "Ashish"<< endl;
        }
    }
    
}


Comments

Submit
0 Comments
More Questions

400B - Inna and New Matrix of Candies
870B - Maximum of Maximums of Minimums
1600E - Array Game
1149A - Prefix Sum Primes
277A - Learning Languages
769A - Year of University Entrance
1738A - Glory Addicts
1738C - Even Number Addicts
1064B - Equations of Mathematical Magic
384A - Coder
1738B - Prefix Sum Addicts
1352D - Alice Bob and Candies
1316D - Nash Matrix
1548B - Integers Have Friends
348A - Mafia
315B - Sereja and Array
204A - Little Elephant and Interval
385B - Bear and Strings
114C - Grammar Lessons
1427A - Avoiding Zero
583A - Asphalting Roads
1358B - Maria Breaks the Self-isolation
828A - Restaurant Tables
1735A - Working Week
1735D - Meta-set
1735B - Tea with Tangerines
1735C - Phase Shift
1321C - Remove Adjacent
281B - Nearest Fraction
1043A - Elections