fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,k,maxn,maxx;
  4. struct node{
  5. int x,y,z,cnt;
  6. }a[1000001];
  7. struct nod{
  8. int x,y,z;
  9. bool operator<(const nod&s)const{
  10. if(x!=s.x)return x<s.x;
  11. if(y!=s.y)return y<s.y;
  12. return z<s.z;
  13. }
  14. };
  15. map<nod,int>mp;
  16. int main(){
  17. ios::sync_with_stdio(0);
  18. cin.tie(0),cout.tie(0);
  19. cin>>n>>k;
  20. for(int i=1;i<=k;i++){
  21. int x,y,z;
  22. cin>>x>>y>>z;
  23. mp[nod{x,y,z}]++;
  24. }
  25. int rn=0;
  26. for(auto i:mp){
  27. a[++rn]=node{i.first.x,i.first.y,i.first.z,i.second};
  28. // cin>>a[i].x>>a[i].y>>a[i].z;
  29. }
  30. int c=1<<n;
  31. for(int i=0;i<=c;i++){
  32. int cnt=0;
  33. for(int j=1;j<=rn;j++){
  34. int x=((i>>(a[j].x))&1)==1;
  35. int y=((i>>(a[j].y))&1)==0;
  36. int z=((i>>(a[j].z))&1)==0;
  37. if(x&&y&&z)cnt++;
  38. }
  39. if(cnt>maxn)maxn=cnt,maxx=1;
  40. else if(cnt==maxn)maxx++;
  41. }
  42. cout<<maxn<<' '<<maxx;
  43. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
0 2