forked from shivprime94/Data-Structure-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroups.cpp
More file actions
46 lines (46 loc) · 815 Bytes
/
groups.cpp
File metadata and controls
46 lines (46 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
https://codeforces.com/contest/1598/problem/B
*/
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main(){
int t;scanf("%d",&t);
while(t--){
int n;scanf("%d",&n);
// std::vector<int> v;
// vector<vector<int>> v;
int v[n][5];
for(int i=0;i<n;i++){
for(int j=0;j<5;j++){
cin>>v[i][j];
}
}
int flag=0;
for(int i=0;i<5;i++){
for(int j=i+1;j<5;j++){
int cnta=0,cntb=0,cntab=0,cnt=0;
for(int k=0;k<n;k++){
if(v[k][i]==1 && v[k][j]==0)
cnta++;
if(v[k][j]==1 && v[k][i]==0)
cntb++;
if(v[k][i]==0 && v[k][j]==0){
cnt++;break;
}
}
if(cnt!=0)
continue;
else if(cnta>n/2 || cntb>n/2)
continue;
else{
flag=1;break;
}
}
}
if(flag==0)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
}