国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

HDU 6016

2019-11-06 06:24:25
字體:
來源:轉載
供稿:網友

Count the Sheep

Time Limit: 3000/1500 MS (java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 852    Accepted Submission(s): 362PRoblem DescriptionAltough Skipping the class is happy, the new term still can drive luras anxious which is of course because of the tests! Luras became worried as she wanted to skip the class, as well as to attend the BestCoder and also to prepare for tests at the same time.However, As the result of preparing for tests, luras had no time to practice programing. She didn't want to lose her rating after attending BC. In the end, she found BCround92's writer snowy_smile for help, asking him to leak her something.Snowy_smile wanted to help while not leaking the problems. He told luras, the best thing to do is to take a good rest according to the following instructions first."Imagine you are on the endless grassland where there are a group of sheep. And n sheep of them are silent boy-sheep while m sheep are crying girl-sheep. And there are k friend-relationships between the boy-sheep and girl-sheep.Now You can start from any sheep, keep counting along the friend relationship. If you can count 4 different sheep, you will exceed 99% sheep-counters and fall asleep."Hearing of the strange instructions, luras got very shocked. Still, she kept counting. Sure enough, she fell asleep after counting 4 different sheep immediately. And, she overslept and missed the BestCoder in the next day. At a result, she made it that not losing her rating in the BCround92!!!However, you don't have the same good luck as her. Since you have seen the 2nd problem, you are possible to have submitted the 1st problem and you can't go back.So, you have got into an awkward position. If you don't AC this problem, your rating might fall down.You question is here, please, can you tell that how many different 4-sheep-counting way luras might have before her sleep?In another Word, you need to print the number of the "A-B-C-D" sequence, where A-B, B-C, C-D are friends and A,B,C,D are different. InputThe first line is an integer T which indicates the case number.and as for each case, there are 3 integers in the first line which indicate boy-sheep-number, girl-sheep-number and friend-realationship-number respectively.Then there are k lines with 2 integers x and y in each line, which means the x-th boy-sheep and the y-th girl-sheep are friends.It is guaranteed that——There will not be multiple same relationships.1 <= T <= 1000for 30% cases, 1 <= n, m, k <= 100for 99% cases, 1 <= n, m, k <= 1000for 100% cases, 1 <= n, m, k <= 100000 OutputAs for each case, you need to output a single line.there should be 1 integer in the line which represents the number of the counting way of 4-sheep-sequence before luras's sleep. Sample Input
32 2 41 11 22 12 23 1 31 12 13 13 3 31 12 12 2 Sample Output
802

已經AC過的代碼:

#include<cstdio>#include<iostream>#include<vector>#include<cstring>using namespace std;long long d1[100010],d2[100010];struct edge{    int x,y;};edge e[100010];int main(){    int t,n,m,k;    scanf("%d",&t);    while(t--)    {        long long ans=0;        memset(d1,0,sizeof(d1));        memset(d2,0,sizeof(d2));        scanf("%d %d %d",&n,&m,&k);        for(int i=0;i<k;i++)        {            scanf("%d %d",&e[i].x,&e[i].y);            d1[e[i].x]++;            d2[e[i].y]++;        }        for(int i=0;i<k;i++)        {            ans+=(d1[e[i].x]-1)*(d2[e[i].y]-1);        }        cout<<ans*2<<endl;    }    return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桦甸市| 专栏| 鸡泽县| 新宾| 班玛县| 调兵山市| 大田县| 天长市| 石台县| 保定市| 海伦市| 江山市| 陕西省| 兴化市| 涡阳县| 阜南县| 大姚县| 荥阳市| 教育| 姚安县| 白朗县| 安吉县| 普兰店市| 龙口市| 墨江| 浮山县| 黄山市| 巴南区| 安阳市| 甘泉县| 青海省| 榆林市| 宽城| 滁州市| 万宁市| 手游| 左权县| 梅河口市| 鲁甸县| 准格尔旗| 凤山市|