当前位置:网站首页>7-1 understand everything (20 points)

7-1 understand everything (20 points)

2022-07-06 16:03:00 It's Xiao Zhang, ZSY

2021 RoboCom World robot developer competition - Undergraduate group ( Preliminaries )
7-1 Know everything. (20 branch )
 Insert picture description here

as everyone knows , There are many words on the Internet that are not easy to say directly , However, some vague pictures can still make netizens understand what you are talking about . However, we must still give a heavy blow to this kind of speech , So please implement a simple matching algorithm .

Now we have collected some characteristic data of the original image , from N Less than 255 Composed of nonnegative integers , Suppose that for a given number of sheets M Two are also less than 255 The characteristic data of the new graph composed of nonnegative integers , Each data can be calculated from the average of any four different data in the original figure , The new picture is called a similar picture of the original picture . For the given data , Please judge whether it's a similar picture .

Be careful , Different data does not mean different values of data , Instead, you can't take the same data multiple times . For two data with the same value , If you give it twice , You can take it twice .

Input format :
The first line of input is two integers N,K (1 ≤ N ≤ 50, 1 ≤ K ≤ 200), Indicates the number of characteristic data of the collected original drawing and the number of new drawings .

The next action N Less than 255 Non-negative integer , Represent the characteristic data of the original drawing .

final K That's ok , The first number in each line is M Represents the number of characteristic data of the new graph . And then there was M Less than 255 Non-negative integer , Represent the characteristic data of the new graph .

Output format :
For each new picture , If it is a similar picture , Output in one line Yes, Otherwise output No.

sample input :
5 3
4 8 12 20 40
3 11 16 19
3 12 16 19
10 11 11 11 11 11 11 11 11 11 11

sample output :
Yes
No
Yes

#include <bits/stdc++.h>
using namespace std;
double a[8000000],b[205],c[205];
int main(){
    

 int m,n;
 cin>>m>>n;
 for(int i=0;i<m;i++){
    
    cin>>b[i];
 }
 int kk=0;
 for(int i=0;i<m;i++){
    
    for(int j=i+1;j<m;j++){
    
        for(int k=j+1;k<m;k++){
    
            for(int h=k+1;h<m;h++){
    
                a[kk++]=b[i]+b[j]+b[k]+b[h];
            }
        }
    }
 }
 sort(a,a+kk);
 while(n--){
    
    int ss;
    cin>>ss;
    for(int i=0;i<ss;i++){
    
        cin>>c[i];
    }
    int oo=0;
    for(int i=0;i<ss;i++){
    
        int h=lower_bound(a,a+kk,c[i]*4.0)-a;
        if(a[h]!=c[i]*4.0){
    
            oo=1;
        break;
        }
    }
    if(oo==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
 }
  return 0;
}

原网站

版权声明
本文为[It's Xiao Zhang, ZSY]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060919380294.html