【#1】【The2014ACM-ICPC亞洲區(qū)廣州站】訓(xùn)練賽

【A-Dog's Candies】【HDU5127】

Far far away, there live a lot of dogs in the forest. Unlike other dogs, those dogs love candies much more than bones.Every candy has two attributes: the sweetness degree p and the sourness degree q. Different dogs like different candies. A dog also has two attributes: the fondness degree for sweetness x and the fondness degree for sourness y. So the deliciousness degree of a candy for a dog is defined as p×x + q×y.The dog king has a huge candy box. At first, the box is empty. The king can add candies to the box or take some candies from the box and eat them. There are always some dogs who want to know which candies in the box are the most delicious for them. Please help the king to answer their questions.

【Input】

The input consists of at most 10 test cases. For each test case, the first line contains an integer n indicating that there are n candy box operations(1 <= n <= 50000).The following n lines describe the n operations.Each operation contains three integers t, x and y( 0 <= |x|, |y| <= 1e9). The first integer t may be -1, 0, or 1.If t equals -1, it means that a candy in the box with sweetness degree x and sourness degree y is eaten by the dog king.If t equals 1, it means that a candy with sweetness degree x and sourness degree y is added to the candy box.If t equals 0, it means that a dog with sweetness fondness degree x and sourness fondness degree y wants to know the maximal deliciousness degree of the candies in the box for him. It is guaranteed that every candy is unique in the box. The input ends by n = 0.

【Output】

For each operation in which t equals to 0, you should print the maximal deliciousness degree of the best candy for the dog.

題目大意:狗狗們愛吃糖果粱檀,糖果有2個(gè)屬性,甜度值p和酸度值q.狗狗們對(duì)糖果的喜愛程度為嗜甜度x和嗜酸度y收夸,那么糖果的美味程度定義為px+qy.現(xiàn)在有3種操作,-1,0,1.-1 x y表示刪除甜度x酸度y的糖践惑,1 x y表示增添甜度x酸度y的糖妙痹,0 x y 表示屬性為x,y的狗狗查詢于他而言最好吃的糖果是哪一個(gè)寇荧。

【題解】注意到本題的時(shí)限為30秒最易,所以vector暴力模擬即可。

int n;

struct node{

long long x,y;

};

inline long long mul(node a,node b){return a.xb.x+a.yb.y;}

inline bool same(node a,node b){return a.x==b.x && a.y==b.y;}

vectorv;

int main(){

while(1){

   scanf("%d",&n);if(n==0) break;

   int op,i;node p;

   while(n--){

       scanf("%d %lld %lld",&op,&p.x,&p.y);

       if(op==1) v.push_back(p);

       if(op==0){

          long long ans=-999999999999999999ll;

          for(i=0;i

           printf("%lld\n",ans);

       }

       if(op==-1)

          for(vector::iterator it=v.begin();it!=v.end();it++){

              node tp=*it; if(same(tp,p)){v.erase(it);break;}

          }

   }

   while(!v.empty()) v.pop_back();

}

return 0;

}

【B - The E-pang Palace】【HDU - 5128】

E-pang Palace was built in Qin dynasty by Emperor Qin Shihuang in Xianyang, Shanxi Province. It was the largest palace ever built by human. It was so large and so magnificent that after many years of construction, it still was not completed. Building the great wall, E-pang Palace and Qin Shihuang's tomb cost so much labor and human lives that people rose to fight against Qin Shihuang's regime.Xiang Yu and Liu Bang were two rebel leaders at that time. Liu Bang captured Xianyang -- the capital of Qin. Xiang Yu was very angry about this, and he commanded his army to march to Xianyang. Xiang Yu was the bravest and the strongest warrior at that time, and his army was much more than Liu Bang's. So Liu Bang was frighten and retreated from Xianyang, leaving all treasures in the grand E-pang Palace untouched. When Xiang Yu took Xianyang, he burned E-pang Palce. The fire lasted for more than three months, renouncing the end of Qin dynasty.Several years later, Liu Bang defeated Xiangyu and became the first emperor of Han dynasty. He went back to E-pang Palace but saw only some pillars left. Zhang Liang and Xiao He were Liu Bang's two most important ministers, so Liu Bang wanted to give them some awards. Liu Bang told them: "You guys can make two rectangular fences in E-pang Palace, then the land inside the fences will belongs to you. But the corners of the rectangles must be the pillars left on the ground, and two fences can't cross or touch each other." To simplify the problem, E-pang Palace can be consider as a plane, and pillars can be considered as points on the plane. The fences you make are rectangles, and you MUST make two rectangles. Please note that the rectangles you make must be parallel to the coordinate axes. The figures below shows 3 situations which are not qualified(Thick dots stands for pillars): Zhang Liang and Xiao He wanted the total area of their land in E-pang Palace to be maximum. Please bring your computer and go back to Han dynasty to help them so that you may change the history.

【Input】

There are no more than 15 test case. For each test case: The first line is an integer N, meaning that there are N pillars left in E-pang Palace(4 <=N <= 30). Then N lines follow. Each line contains two integers x and y (0 <= x,y <= 200), indicating a pillar's coordinate. No two pillars has the same coordinate. The input ends by N = 0.

【Output】

For each test case, print the maximum total area of land Zhang Liang and Xiao He could get. If it was impossible for them to build two qualified fences, print "imp".

【題目大意】:前文廢話極多粒没,大意為筛婉,阿房宮燒毀后地面留下n個(gè)木樁,給出坐標(biāo)信息●桑現(xiàn)在兩個(gè)人圈地爽撒,要求圈地為矩形,且矩形的邊不能相“觸碰“响蓉,即如果共有某個(gè)木樁也認(rèn)為是”觸碰“的∷段穑現(xiàn)在求最大占地面積,如果找不到輸出imp枫甲。

【題解】暴力搜索點(diǎn)即可源武,但注意到:矩形的嵌套是不違規(guī)的扼褪,而且面積只計(jì)算外圈大矩形的面積。其他的普通做即可.

int n,m[202][202];

struct node

{

int x,y;

}point[33];

bool cmp(node a, node b)

{

if(a.x < b.x)return true;

if(a.x > b.x)return false;

if(a.y < b.y)return true;

return false;

}

bool judge(node a,node b,node c,node d)

{

if(a.x>=b.x || a.y>=b.y || c.x>=d.x || c.y>=d.y)return false;

if(m[a.x][b.y]==0 || m[b.x][a.y]==0 || m[c.x][d.y]==0 || m[d.x][c.y]==0)return false;

if(c.xb.x &&d.y >b.y

|| c.x>a.x&&c.y>a.y &&d.x

if(c.x <= b.x && c.y<=b.y)return false;

return true;

}

inline int size(node a,node b,node c,node d)

{

int ans=0;

   if(c.xb.x &&d.y >b.y

|| c.x>a.x&&c.y>a.y &&d.x

ans+=(b.x-a.x)*(b.y-a.y);

ans+=(d.x-c.x)*(d.y-c.y);

return ans;

}

int main(){

int i,j,k,l,ans;

while(true)   {

   scanf("%d",&n);

   if(n==0)break;

   ans=-1;memset(m,0,sizeof(m));

   for(i=1;i<=n;i++){

       scanf("%d%d",&point[i].x,&point[i].y);

       m[point[i].x][point[i].y]=1;

   }

   for(i=1;i<=n;i++)

       for(j=1;j<=n;j++)

          for(k=1;k<=n;k++)

              for(l=1;l<=n;l++)

                 if(judge(point[i],point[j],point[k],point[l]))

                     ans=max(ans,size(point[i],point[j],point[k],point[l]));

   if(ans==-1)printf("imp\n");

   else printf("%d\n",ans);

}

}

【D - Signal Interference】【HDU - 5130】

http://blog.sina.com.cn/s/blog_be010f940102ylne.html

【E - Song Jiang's rank list】【HDU - 5131】

《Shui Hu Zhuan》粱栖,also 《Water Margin》was written by Shi Nai'an -- an writer of Yuan and Ming dynasty. 《Shui Hu Zhuan》is one of the Four Great Classical Novels of Chinese literature. It tells a story about 108 outlaws. They came from different backgrounds (including scholars, fishermen, imperial drill instructors etc.), and all of them eventually came to occupy Mout Liang(or Liangshan Marsh) and elected Song Jiang as their leader. In order to encourage his military officers, Song Jiang always made a rank list after every battle. In the rank list, all 108 outlaws were ranked by the number of enemies he/she killed in the battle. The more enemies one killed, one's rank is higher. If two outlaws killed the same number of enemies, the one whose name is smaller in alphabet order had higher rank. Now please help Song Jiang to make the rank list and answer some queries based on the rank list.

【Input】There are no more than 20 test cases. For each test case:

The first line is an integer N (0

【Output】For each test case, print the rank list first. For this part in the output ,each line contains an outlaw's name and the number of enemies he killed. Then, for each name in the query of the input, print the outlaw's rank. Each outlaw had a major rank and a minor rank. One's major rank is one plus the number of outlaws who killed more enemies than him/her did.One's minor rank is one plus the number of outlaws who killed the same number of enemies as he/she did but whose name is smaller in alphabet order than his/hers. For each query, if the minor rank is 1, then print the major rank only. Or else Print the major rank, blank , and then the minor rank. It's guaranteed that each query has an answer for it.

【題目大意】水滸好漢排座次迎捺,殺人多的排前面,相同殺人看名字查排,按字典序排序。先輸出座次抄沮,然后根據(jù)名稱輸出排名跋核,如果有并列的輸出并列后第幾。

【題解】結(jié)構(gòu)體排序

struct node

{

char s[60];

int x,rk1,rk2;

}a[210];

bool cmp(node x,node y)

{

if (x.x!=y.x) return x.x>y.x;

return (strcmp(x.s,y.s)<0)?1:0;

}

int main()

{

int n,m,i,num,cnt;char c[60];

while (1)

{

   scanf("%d",&n);

   if (n==0) break;

   for (i=1;i<=n;i++)

    cin>>a[i].s>>a[i].x;

   sort(a+1,a+1+n,cmp);

   for (i=1;i<=n;i++)

    cout<<a[i].s<<" "<<a[i].x<<endl;

   num=cnt=a[1].rk1=a[1].rk2=1;

   for (i=2;i<=n;i++)

    if (a[i].x!=a[i-1].x) {num+=cnt;a[i].rk1=num;a[i].rk2=cnt=1;}

    else {a[i].rk1=num;a[i].rk2=++cnt;}

   scanf("%d",&m);

   while (m--)

   {

       cin>>c;

       for (i=1;i<=n;i++)

        if (strcmp(c,a[i].s)==0) break;

       if (a[i].rk2==1) printf("%d\n",a[i].rk1);

       else printf("%d %d\n",a[i].rk1,a[i].rk2);     

   }

}

return 0;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末叛买,一起剝皮案震驚了整個(gè)濱河市砂代,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌率挣,老刑警劉巖刻伊,帶你破解...
    沈念sama閱讀 218,640評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異椒功,居然都是意外死亡捶箱,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,254評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門动漾,熙熙樓的掌柜王于貴愁眉苦臉地迎上來丁屎,“玉大人,你說我怎么就攤上這事旱眯〕看ǎ” “怎么了?”我有些...
    開封第一講書人閱讀 165,011評(píng)論 0 355
  • 文/不壞的土叔 我叫張陵删豺,是天一觀的道長(zhǎng)共虑。 經(jīng)常有香客問我,道長(zhǎng)呀页,這世上最難降的妖魔是什么妈拌? 我笑而不...
    開封第一講書人閱讀 58,755評(píng)論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮赔桌,結(jié)果婚禮上供炎,老公的妹妹穿的比我還像新娘。我一直安慰自己疾党,他們只是感情好音诫,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,774評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著雪位,像睡著了一般竭钝。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,610評(píng)論 1 305
  • 那天香罐,我揣著相機(jī)與錄音卧波,去河邊找鬼。 笑死庇茫,一個(gè)胖子當(dāng)著我的面吹牛垫言,可吹牛的內(nèi)容都是我干的犹撒。 我是一名探鬼主播,決...
    沈念sama閱讀 40,352評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼瓶盛!你這毒婦竟也來了幕袱?” 一聲冷哼從身側(cè)響起访得,我...
    開封第一講書人閱讀 39,257評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤州既,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后羔巢,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體望忆,經(jīng)...
    沈念sama閱讀 45,717評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,894評(píng)論 3 336
  • 正文 我和宋清朗相戀三年竿秆,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了启摄。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,021評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡袍辞,死狀恐怖鞋仍,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情搅吁,我是刑警寧澤威创,帶...
    沈念sama閱讀 35,735評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站谎懦,受9級(jí)特大地震影響肚豺,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜界拦,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,354評(píng)論 3 330
  • 文/蒙蒙 一吸申、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧享甸,春花似錦截碴、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,936評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至蚯嫌,卻和暖如春哲虾,著一層夾襖步出監(jiān)牢的瞬間丙躏,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,054評(píng)論 1 270
  • 我被黑心中介騙來泰國(guó)打工束凑, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留晒旅,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,224評(píng)論 3 371
  • 正文 我出身青樓汪诉,卻偏偏與公主長(zhǎng)得像废恋,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子扒寄,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,974評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容