日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

(第六场)Singing Contest 【模拟】

發(fā)布時間:2025/4/16 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 (第六场)Singing Contest 【模拟】 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題目鏈接:https://www.nowcoder.com/acm/contest/144/A

標題:A、Singing Contest

| 時間限制:1 秒 | 內(nèi)存限制:256M

Jigglypuff is holding a singing contest. There are 2n singers indexed from 1 to 2n participating in the contest. The rule of this contest is like the knockout match. That is, in the first round, singer 1 competes with singer 2, singer 3 competes with singer 4 and so on; in the second round, the winner of singer 1 and singer 2 competes with the winner of singer 3 and singer 4 and so on. There are n rounds in total. Each singer has prepared n songs before the contest. Each song has a unique pleasantness. In each round, a singer should sing a song among the songs he prepared. In order not to disappoint the audience, one song cannot be performed more than once. The singer who sings the song with higher pleasantness wins. Now all the singers know the pleasantness of songs prepared by all the others. Everyone wants to win as many rounds as he can. Assuming that singers choose their song optimally, Jigglypuff wants to know which singer will win the contest?
輸入描述: The input starts with one line containing exactly one integer t which is the number of test cases. (1 ≤ t ≤ 10)

For each test case, the first line contains exactly one integer n where 2n is the number of singers. (1 ≤ n ≤ 14)

Each of the next 2n lines contains n integers where aij is the pleasantness of the j-th song of the ith singer. It is guaranteed that all these 2nx n integers are pairwise distinct. (1≤ aij ≤ 109)

輸出描述: For each test case, output "Case #x: y" in one line (without quotes), where x is the test case number (starting from 1) and y is the index of the winner.

示例 1

輸入

2

1

1

2

2

1 8

2 7

3 4

5 6

輸出

Case #1: 2

Case #2: 4

?

題意概括:

歌唱比賽,有2^N位歌手,每位歌手準備N首歌,每首歌可以得到的分數(shù)不同,每首歌只能唱一次。1和2比,3和4比...贏了的繼續(xù)比下去,問最后誰會獲勝。每位歌手的歌曲得分用一個二維矩陣表示,A[ i ][ j ]表示第 i 位歌手唱第 j 首歌可以得到的分數(shù)。

官方題解:

由于每個選?手的策略略都是盡可能贏,所以他該認輸?shù)臅r候只能認輸。
能贏的時候只要選權值?大于對?方最?大值的最?小值,?大的留留在后?面不不會 更更差。
直接模擬即可。

解題思路:

每次對決,遵循貪心的原則,排序之后lower_bound()可以打敗對手的最小值,遍歷對決可以用DFS二分一下。

?

AC code:

1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAXN = (1<<14)+15; 5 int f[MAXN][15]; 6 int N; 7 8 int dfs(int l, int r) 9 { 10 if(r == l+1) 11 { 12 sort(f[l], f[l]+N); 13 sort(f[r], f[r]+N); 14 int a = lower_bound(f[l], f[l]+N, f[r][N-1])-f[l]; 15 int b = lower_bound(f[r], f[r]+N, f[l][N-1])-f[r]; 16 if(a == N) 17 { 18 f[r][b] = 0; 19 return r; 20 } 21 else 22 { 23 f[l][a] = 0; 24 return l; 25 } 26 } 27 else 28 { 29 int mid = (l+r)>>1; 30 int x = dfs(l, mid); 31 int y = dfs(mid+1, r); 32 sort(f[x], f[x]+N); 33 sort(f[y], f[y]+N); 34 int a = lower_bound(f[x], f[x]+N, f[y][N-1])-f[x]; 35 int b = lower_bound(f[y], f[y]+N, f[x][N-1])-f[y]; 36 if(a == N) 37 { 38 f[y][b] = 0; 39 return y; 40 } 41 else 42 { 43 f[x][a] = 0; 44 return x; 45 } 46 } 47 } 48 49 int main() 50 { 51 int T_case; 52 scanf("%d", &T_case); 53 int cnt = 0; 54 while(T_case--) 55 { 56 scanf("%d", &N); 57 for(int i = 1; i <= (1<<N); i++) 58 for(int j = 0; j < N; j++) 59 { 60 scanf("%d", &f[i][j]); 61 } 62 printf("Case #%d: %d\n", ++cnt, dfs(1, (1<<N))); 63 } 64 return 0; 65 } View Code

?

轉(zhuǎn)載于:https://www.cnblogs.com/ymzjj/p/9438777.html

《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的(第六场)Singing Contest 【模拟】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 天天狠狠操 | 婷婷综合av | 内射后入在线观看一区 | 精品女厕偷拍一区二区 | 亚洲福利精品 | 波多野结衣理论片 | 国产精品视频你懂的 | 欧美一区中文字幕 | www.youjizz.com日本 | 日本三级少妇 | 性xxxx| 女人扒开腿让男人桶爽 | 亚洲大胆视频 | 国模在线 | 好吊一区 | 久久99精品国产麻豆婷婷洗澡 | 国产精欧美一区二区三区蓝颜男同 | 午夜成人免费电影 | 成人涩涩网站 | 亚洲国产精品va在线 | 久久网中文字幕 | 禁片天堂 | 日本天堂网在线观看 | 亚洲美女爱爱 | www.夜夜夜 | h毛片| 777777av | 日日夜夜狠狠操 | 国产一级做a爰片久久毛片男男 | 天堂新版8中文在线8 | 三上悠亚久久 | 91视频黄版 | 欧美极品在线观看 | 黄色激情在线观看 | 欧美啪啪一区二区 | 秋霞在线观看视频 | 国产精品四虎 | 黄色av网址在线观看 | ts人妖另类精品视频系列 | 久久亚洲精品国产 | 色丁香在线| 你懂的国产视频 | 很黄很色的视频 | 天天射天天干天天操 | 国产日韩精品一区 | 香蕉人妻av久久久久天天 | 日韩1页 | 91精品99| 西西大胆午夜视频 | 国产性爱精品视频 | 欧美成人福利 | 久久涩涩| 亚洲www在线观看 | 中文字幕网站在线观看 | 国产视频69 | 天天爱综合 | 成人黄色在线看 | 日韩在线免费观看av | 欧美精品一区二区久久婷婷 | 国产又粗又猛又爽又黄无遮挡 | 欧美又大又硬又粗bbbbb | 两个女人互添下身爱爱 | 亚洲精品高清无码视频 | 日韩欧美视频在线 | 精品国产一区二区三 | 精品国产99久久久久久 | 亚洲激情成人 | 在线免费观看av网 | 亚色一区| 亚洲欧洲在线播放 | 朝桐光一区二区三区 | 久久特黄 | 脱美女衣服亲摸揉视频 | 日本福利网站 | 欧美第四页 | 成人免费毛片片v | 男人和女人在床的app | 一级特黄特色的免费大片视频 | 福利资源在线观看 | 男人懂得网站 | 神秘马戏团在线观看免费高清中文 | 穿扒开跪着折磨屁股视频 | 欧美激情视频在线 | 丝袜熟女一区二区 | 99国产精品久久久久久久成人热 | 国产98在线 | 久久伊人精品视频 | 日日夜夜精品 | 四虎免费av| 神秘马戏团在线观看免费高清中文 | 手机av在线播放 | 亚洲一区二区三区色 | 亚洲天堂男 | 亚洲第一av网站 | 亚洲成人激情av | 国产精品久久久免费视频 | 亚洲欧美日韩国产一区 | 天海翼av| 女生扒开尿口让男生桶 |