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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

校省选赛第一场A题Cinema题解

發布時間:2024/4/15 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 校省选赛第一场A题Cinema题解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天是學校省選的第一場比賽,0戰績收工,死死啃著A題來做,偏偏一直WA在TES1。

賽后,才發現,原來要freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);……

后來交了一下,Accepted了……煩惱!!!!!當是一個教訓吧。

題目Description input input.txt output output.txtOverall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favorite actors. He watched the movie trailers for the next month and wrote the following information for every movie: the movie title, the number of actors who starred in it, and the identifiers of these actors. Besides, he managed to copy the movie titles and how many actors starred there, but he didn't manage to write down the identifiers of some actors. Vasya looks at his records and wonders which movies may be his favourite, and which ones may not be. Once Vasya learns the exact cast of all movies, his favorite movies will be determined as follows: a movie becomes favorite movie, if no other movie from Vasya's list has more favorite actors.Help the boy to determine the following for each movie: whether it surely will be his favourite movie; whether it surely won't be his favourite movie; can either be favourite or not.InputThe first line of the input contains two integers m and k (1?≤?m?≤?100,?1?≤?k?≤?m) — the number of actors in Berland and the number of Vasya's favourite actors.The second line contains k distinct integers ai (1?≤?ai?≤?m) — the identifiers of Vasya's favourite actors.The third line contains a single integer n (1?≤?n?≤?100) — the number of movies in Vasya's list.Then follow n blocks of lines, each block contains a movie's description. The i-th movie's description contains three lines:the first line contains string si (si consists of lowercase English letters and can have the length of from 1 to 10 characters, inclusive) — the movie's title, the second line contains a non-negative integer di (1?≤?di?≤?m) — the number of actors who starred in this movie, the third line has di integers bi,?j (0?≤?bi,?j?≤?m) — the identifiers of the actors who star in this movie. If bi,?j?=?0, than Vasya doesn't remember the identifier of the j-th actor. It is guaranteed that the list of actors for a movie doesn't contain the same actors.All movies have distinct names. The numbers on the lines are separated by single spaces.OutputPrint n lines in the output. In the i-th line print:0, if the i-th movie will surely be the favourite;1, if the i-th movie won't surely be the favourite;2, if the i-th movie can either be favourite, or not favourite. Sample Input Input5 3 1 2 3 6 firstfilm 3 0 0 0 secondfilm 4 0 0 4 5 thirdfilm 1 2 fourthfilm 1 5 fifthfilm 1 4 sixthfilm 2 1 0Output2 2 1 1 1 2Input5 3 1 3 5 4 jumanji 3 0 0 0 theeagle 5 1 2 3 4 0 matrix 3 2 4 0 sourcecode 2 2 4Output2 0 1 1HintNote to the second sample:Movie jumanji can theoretically have from 1 to 3 Vasya's favourite actors.Movie theeagle has all three favourite actors, as the actor Vasya failed to remember, can only have identifier 5.Movie matrix can have exactly one favourite actor.Movie sourcecode doesn't have any favourite actors. Thus, movie theeagle will surely be favourite, movies matrix and sourcecode won't surely be favourite, and movie jumanji can be either favourite (if it has all three favourite actors), or not favourite.看題就看得很糾結啦~不過總體來說大概明白。
思路就是:
1.如果一個電影最好的情況都比其他電影最差的情況差,那么該電影一定不是最好的,即狀態為1
2.再判斷如果一個電影不滿足最差的情況都比其他電影最好的情況好,那么該電影不一定是最好的,即狀態為2
3.最后剩余的就是最好的了。
特別繞啦~關鍵在于,一定不是最好的,不一定是最好的,略坑。
/*******************************************************************************/ /* OS : 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 UTC 2013 GNU/Linux* Compiler : g++ (GCC) 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)* Encoding : UTF8* Date : 2014-04-01* All Rights Reserved by yaolong. *****************************************************************************/ /* Description: *************************************************************** *****************************************************************************/ /* Analysis: ****************************************************************** *****************************************************************************/ /*****************************************************************************/#include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<cmath> using namespace std; class Movie { public:string name;int num;int stat;int like;int hate;int zero;vector<int> act;Movie() {};void resiz(){act.resize(num);}};int main() {freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);int cases=0;int m,k,mov_num,i,j,tmp;int fav[120];vector<Movie> mv;while(cin>>m>>k){memset(fav,0,sizeof(fav));for(i=0; i<k; i++){cin>>tmp;fav[tmp]=1;}cin>>mov_num;mv.clear();mv.resize(mov_num);for(i=0; i<mov_num; i++){cin>>mv[i].name;cin>>mv[i].num;mv[i].resiz();for(j=0; j<mv[i].num; j++){cin>>mv[i].act[j];}}int maxlike=-1;int minlike=-1;for(i=0; i<mov_num; i++){mv[i].zero=0;mv[i].hate=0;mv[i].like=0;for(j=0; j<mv[i].act.size(); j++){//統計0的個數if(mv[i].act[j]==0){mv[i].zero++;}else{if(fav[mv[i].act[j]]){mv[i].like++;}else{mv[i]. hate++;}}}}for(i=0; i<mov_num; i++){int tmpbest=mv[i].like+min(mv[i].zero,k-mv[i].like); //最好的情況int tmpworst=mv[i].like+max(0,mv[i].zero-(m-k-mv[i].hate)); //最壞的情況int cnt=0;for(j=0; j<mov_num; j++){if(i!=j){if(tmpbest<mv[j].like+max(0,mv[j].zero-(m-k-mv[j].hate))){mv[i].stat=1; //不滿足最好的大于其他最小的,那么肯定不是最好的break;}}}for(j=0; j<mov_num&&mv[i].stat!=1; j++){if(i!=j){if(tmpworst<mv[j].like+min(mv[j].zero,k-mv[j].like)){mv[i].stat=2 ; //不滿足最差的大于其他最好的,那么這個就肯定不是最好的!同時又不是最差的,那么就是不確定的break;}}}mv[i].stat= mv[i].stat>=1?mv[i].stat:0; //如果沒有被確定不是最好的或者未確定的,那么就是最右的}for(i=0; i<mov_num; i++){cout<<mv[i].stat<<endl;}}return 0;}
?


轉載于:https://www.cnblogs.com/dengyaolong/p/3697238.html

總結

以上是生活随笔為你收集整理的校省选赛第一场A题Cinema题解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美高清一区 | 啪啪亚洲 | 亚洲干| 娇小萝被两个黑人用半米长 | 天天干天天操天天摸 | 人成在线视频 | 精品美女在线观看 | 射射综合网| 狠狠综合一区 | 免费av一级 | 亚洲视频综合 | 亚洲视频成人 | 黄色亚洲视频 | 中文字幕35页 | 女性生殖扒开酷刑vk | 黄色wwww| 99夜色| 精品嫩模一区二区三区 | 亚洲天堂中文字幕在线观看 | 欧美色图首页 | 国产一区二区观看 | 少妇一级淫片免费视频 | 国产免费一区二区三区四区五区 | 久久亚洲美女 | 久草热线 | 亚洲精品乱码久久久久久蜜桃动漫 | 亚洲三页 | 超碰在线网址 | 一本色道久久综合亚洲精品酒店 | 国产人成精品 | 一本一道久久a久久精品综合 | 麻豆av一区二区三区在线观看 | 国产女主播喷水高潮网红在线 | 蜜臀av性久久久久av蜜臀妖精 | 少妇又紧又色又爽又刺激 | 日韩亚洲精品中文字幕 | 蜜桃无码一区二区三区 | 作爱视频在线 | 999国产精品视频 | av成人天堂 | 国产又粗又猛又黄又爽的视频 | hd丰满圆润的女人hd | 黄色三级免费网站 | 日韩黄色av| 免费乱淫视频 | 以女性视角写的高h爽文 | 成年人的黄色片 | 中文字幕一二三 | 五月婷婷影院 | 婷婷六月综合网 | 亚洲第一网址 | 久草大| 午夜精品网站 | 在线不卡毛片 | 五月激情av| 天堂av网站 | 日韩一级片一区二区 | 在线一区二区不卡 | 91亚洲专区 | 男人天堂成人 | 日韩一区二区免费在线观看 | 土耳其xxxx性hd极品 | 黄色成人在线网站 | 国产精品国色综合久久 | 午夜av毛片| 亚洲黄色一区二区 | 一本之道高清无码视频 | 老女人一毛片 | 日操操| 91精品视频一区二区三区 | 亚洲精品视频国产 | 青青草视频在线观看 | 久久久久久久国产精品美女 | 另类综合小说 | 三级网站免费观看 | 激情四射综合网 | 天天操 夜夜操 | 国产福利小视频在线 | 亚洲福利视频在线 | 修仙淫交(高h)h文 | 中国美女囗交视频 | 国产精品美女久久久久久 | 美女干b视频 | 精品久久久久久无码人妻 | 精品无码国产一区二区三区51安 | 久久久精品美女 | 欧美女优在线 | 国产国语亲子伦亲子 | 成人另类小说 | 国产乱码一区二区三区在线观看 | 99riav国产精品视频 | 日韩精品一区在线观看 | 意大利少妇愉情理伦片 | av中文在线观看 | 在线观看91av | 免费在线观看成人av | 久久精品h | 欧美激情视频一区二区三区不卡 | 美女裸体网站久久久 |