# Algorithm training black and white impermanence

/*Problem description
The students in a dormitory are going to play a game after finishing their academic study: the game is like this,
Every head is pasted with a piece of white or black paper. Now everyone will say "I
See x white paper and y black paper ", and know that the person with white paper on his head is telling the truth
Everyone with black paper on his head tells a lie. Now you are required to judge who has white paper on his head,
If there is no solution, output "NoSolution."; if there are multiple solutions,
The number of the person who pastes the white bar in each answer is arranged according to the size and then forms a number(
For example, the first person and the third person have white paper strips on their heads, so the number is 13;
If the 6th, 7th and 8th person pastes white paper, then the number is 678)
Output the minimum number (if all the black notes are satisfied, then output 0)
Input format
The first line is an integer n, and the next line I in the N line has two integers x and y, respectively, representing the i-th personal statement“
I see x white and y black.
Output format
A line. If no solution is output, "NoSolution.".
Otherwise, the one with the lowest value in the output answer (see the problem description for details),
If all the black notes are satisfied, then the output is 0
sample input
2
1 0
1 0
sample output
0
sample input
5
3 1
0 4
1 3
4 0
1 3
sample output
35
Data size and engagement
n<=8*/

```#include<stdio.h>
void shuru( int [] ,int [] ,int , int * );
void shuchu( int []  ,int , int  );
int main(void)
{
int n , bj  = 0 ;
scanf("%d" , &n );
int s1[8] ,s2[8] ;
shuru( s1 , s2 , n  , &bj);
shuchu( s1 , n , bj );
return 0 ;
}
void shuchu( int s1[]  ,int n, int  t)
{
if( t != 0 )
{
int tag = 0;
int flg = 0;
int i , j ;
for( i = 0 ; i < n ;i ++ )
{
int sum = 0 ;
if( s1[i] != 0 )
{
for( j = 0 ;j < n ; j ++ )
{
if( i == j )
{
continue;
}
if(s1[i] == s1[j])
{
sum ++ ;
}
if(s1[j] == s1[i] + 1 )
{
sum = 0 ;
}

}
if(sum >= s1[i] && flg <= s1[i])
{
printf("%d", i + 1 );
flg ++ ;
}
}
else
{
for( j = 0 ; j < n ; j ++ )
{
if(s1[j] == 1 )
{
tag ++ ;
}
}
if(tag == 0 )
{
printf("%d", i+1);
tag = -1 ;
}
}
}
if(flg == 0 && tag != -1 )
{
printf("NoSolution");
}
}
else
{
putchar('0');
}

}
void shuru( int s1[] ,int s2[] ,int n , int * bj )
{
int  i ;
for( i = 0 ; i < n ; i ++ )
{
scanf("%d%d" , &s1[i] , &s2[i]);
if( s1[i] == 0 )
{
++ * bj ;
}
}
}
```