CodeForces 444(Div.2)

Posted by Zexin Zhang on November 5, 2017

前记:都发烧了,暂时没得药吃,还在实验室坚持a题,唉
还要写博客,写题解
还要写总结报告给两位指导老师
还有一点都不简单的github

A. Div. 64



Description
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.

Her problem is following: for given string, consisting of only 0 and 1, tell if it’s possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.

Input
In the only line given a non-empty binary string s with length up to 100.

Output
Print «yes» (without quotes) if it’s possible to remove digits required way and «no» otherwise.

Examples

input
100010001
output
yes

input
100
output
no
Note
In the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.
You can read more about binary numeral system representation here: https://en.wikipedia.org/wiki/Binary_system

//codeforces 887a

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <cstdlib>

using namespace std;
int main(){
	int a;
	char b[101];
	int one=0,zero=0;
	int len;
	int flag=0;
	scanf("%s",b);
	len=strlen(b);
	for(int i=len-1;i>=0;i--){
		if(b[i]=='0'){
			zero++;
		}
		if(b[i]=='1'){
			if(zero>=6){
				flag=1;
			}
		}
	}
	if(flag==1){
		printf("yes");
	}
	else
		printf("no");
}






B. Cubes for Masha



Description
Absent-minded Masha got set of n cubes for her birthday.

At each of 6 faces of each cube, there is exactly one digit from 0 to 9. Masha became interested what is the largest natural x such she can make using her new cubes all integers from 1 to x.

To make a number Masha can rotate her cubes and put them in a row. After that, she looks at upper faces of cubes from left to right and reads the number.

The number can’t contain leading zeros. It’s not required to use all cubes to build a number.

Pay attention: Masha can’t make digit 6 from digit 9 and vice-versa using cube rotations.


Input
In first line integer n is given (1 ≤ n ≤ 3) — the number of cubes, Masha got for her birthday.

Each of next n lines contains 6 integers aij (0 ≤ aij ≤ 9) — number on j-th face of i-th cube.

Output
Print single integer — maximum number x such Masha can make any integers from 1 to x using her cubes or 0 if Masha can’t make even 1.

Examples
input
3
0 1 2 3 4 5
6 7 8 9 0 1
2 3 4 5 6 7
output
87
input
3
0 1 3 5 6 8
1 2 4 5 7 8
2 3 4 6 7 9
output
98
Note
In the first test case, Masha can build all numbers from 1 to 87, but she can’t make 88 because there are no two cubes with digit 8.

//未完成

//codeforces 887b

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <cstdlib>

using namespace std;
int cube[4][10];
int dp[101];
int main(){
	memset(cube,0,sizeof(cube));
	memset(dp,0,sizeof(dp));
	int num;
	scanf("%d",&num);
	for(int i=1;i<=num;i++){
		for(int j=1;j<=6;j++){
			scanf("%d",&cube[i][j]);
		}
	}
	for(int i=1;i<=num;++i) {
        for(int j=1;j<=6;++j) {
            dp[cube[i][j]]=1;
            for(int k=1;k<=num;++k) {
                if(k==i) continue;
                for(int l=1;l<=6;++l) {
                    dp[cube[i][j]*10+cube[k][l]]=1;
                }
            }
        }
    }
	for(int i=1;i<99;++i){
		if(dp[i]==0){
			printf("%d\n",i-1);
			break;
		}
	}
}






C.Solution for Cube



Description
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik’s cube 2x2x2.
It’s too hard to learn to solve Rubik’s cube instantly, so she learns to understand if it’s possible to solve the cube in some state using 9
0-degrees rotation of one face of the cube in any direction.

To check her answers she wants to use a program which will for some state of cube tell if it’s possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.

Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.

Output
Print «YES» (without quotes) if it’s possible to solve cube using one rotation and «NO» (without quotes) otherwise.

Examples
input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
output
NO

input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
output
YES
https://en.wikipedia.org/wiki/Rubik’s_Cube

Note
In first test case cube looks like this:

In second test case cube looks like this:

It’s possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.

//codeforces 887c

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cstdlib>

using namespace std;
int c[7][5];
int judge[7];
int flag=0;
void scanc(){
	    scanf("%d%d%d%d",&c[1][1],&c[1][2],&c[1][3],&c[1][4]);
		scanf("%d%d%d%d",&c[3][1],&c[3][2],&c[3][3],&c[3][4]);
		scanf("%d%d%d%d",&c[2][1],&c[2][2],&c[2][3],&c[2][4]);
		scanf("%d%d%d%d",&c[5][1],&c[5][2],&c[5][3],&c[5][4]);
		scanf("%d%d%d%d",&c[6][1],&c[6][2],&c[6][3],&c[6][4]);
		scanf("%d%d%d%d",&c[4][1],&c[4][2],&c[4][3],&c[4][4]);	
}
int main(){
	memset(c,0,sizeof(c));
	memset(judge,0,sizeof(judge));
	scanc();	
	for(int i=1;i<=6;i++){
		if(c[i][1]==c[i][2]&&c[i][1]==c[i][3]&&c[i][1]==c[i][4])
			judge[i]=1;
	}


		if(judge[5]==1&&judge[6]==1)
			if(c[1][1]==c[3][2]&&c[1][3]==c[1][2]&&c[1][3]==c[3][4] || c[3][1]==c[2][2]&&c[3][1]==c[3][3]&&c[3][3]==c[2][4] )
			flag++;
		if(judge[1]==1&&judge[2]==1) 
			if(c[3][1]==c[6][3]&&c[3][1]==c[3][2]&&c[3][2]==c[6][4] || c[3][1]==c[5][3]&&c[3][1]==c[3][2]&&c[3][2]==c[6][4] )
			flag++;
		if(judge[3]==1&&judge[4]==1) 
			if(c[1][1]=c[6][1] || c[1][1]==c[5][3] )
			flag++;
		//printf("%d\n",flag);

	if(flag==1)
		printf("YES");
	else
		printf("NO");
}