L2-005. Set Similarity

Source: Internet
Author: User

Question:

 

The last piece of data in this question is not passed. Let's start with this. We should solve the problem in a few days. Then, we will improve it...

#include <cstdio>#include <cstring>#include <algorithm>#include <set>using namespace std;//<int> s[50];struct node {    int c=0;//zongzhi    set<int > s;};node ans[51];int ch[51];int main(){    int n,x,m,k;    scanf("%d",&n);    for(int i=0;i<n;i++)    {        scanf("%d",&m);        while(m--)        {            scanf("%d",&x);            ans[i].s.insert(x);            //ans[i].c++;        }        ans[i].c=ans[i].s.size();    }    scanf("%d",&k);    int a,b;    node ans1;    while(k--)    {        scanf("%d%d",&a,&b);        ans1.s.clear();                for(set<int>::iterator it=ans[a-1].s.begin();it!=ans[a-1].s.end();it++)        {            ans1.s.insert(*it);                    }        for(set<int>::iterator it=ans[b-1].s.begin();it!=ans[b-1].s.end();it++)        {            ans1.s.insert(*it);            //ans1.c++;        }        int sum=ans1.s.size();        int nc=ans[a-1].c+ans[b-1].c-sum;        //double         printf("%.2f",nc*1.0/sum*100);        printf("%%\n");                           }    return 0;}

 

L2-005. Set Similarity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.