Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- using namespace std;
- #define P printf
- #define S scanf
- int kon , ans , array[1050000],tab[20][20],mx;
- void pro( int k , int round , int sum )
- {
- if ( round == ans +1 )
- {
- array[sum]++;
- mx = max (array[sum] , mx);
- }
- else
- {
- if ( tab[k][round] == 1 ) pro ( k , round + 1 , sum + pow ( 2 , round-1));
- else if ( tab[k][round] == -1) pro ( k , round + 1 , sum );
- else
- {
- pro ( k , round + 1 , sum + pow ( 2 , round-1));
- pro ( k , round + 1 , sum );
- }
- }
- }
- int main()
- {
- int i,j;
- S("%d%d",&kon,&ans);
- for( i=1 ; i<=kon ; i++ )
- {
- for( j =1 ; j <= ans ; j++ )
- {
- S("%d",&tab[i][j]);
- }
- }
- for( i=1 ; i<=kon ; i++ ) pro ( i , 1 ,0 );
- P("%d",kon - mx);
- }
Advertisement
Add Comment
Please, Sign In to add comment