首页 > 代码库 > The 2014 ACMICPC Asia Regional Xian Online

The 2014 ACMICPC Asia Regional Xian Online

【A】

Post Robot

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem Description】
   DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.
   But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.
   After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will make a comment “MAI MAI MAI!”, and go on reading the post.
   In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.
 
【Input】
   A blog article described above, which contains only printable characters(whose ASCII code is between 32 and 127), CR(ASCII code 13, ‘\r’ in C/C++), LF(ASCII code 10, ‘\n’ in C/C++), please process input until EOF. Note all characters are case sensitive.
   The size of the article does not exceed 8KB.
 
【Output】
   Output should contains comments generated by your script, one per line.
 
【Sample Input】
Apple bananaiPad lemon ApplepiSony
233
Tim cook is doubi from Apple
iPhoneipad
iPhone30 is so biiiiiiig Microsoft
makes good App.
 
【Sample Output】
MAI MAI MAI!
MAI MAI MAI!
MAI MAI MAI!
SONY DAFA IS GOOD!
MAI MAI MAI!
MAI MAI MAI!
MAI MAI MAI!
 
【分析】
买买买!!!
直接扫描判断即可。
 
 
【E】

Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Problem Description】
   Here is a game for two players. The rule of the game is described below:
   ● In the beginning of the game, there are a lot of piles of beads.
   ● Players take turns to play. Each turn, player choose a pile i and remove some (at least one) beads from it. Then he could do nothing or split pile i into two piles with a beads and b beads.(a,b > 0 and a + b equals to the number of beads of pile i after removing)
   ● If after a player‘s turn, there is no beads left, the player is the winner.
   Suppose that the two players are all very clever and they will use optimal game strategies. Your job is to tell whether the player who plays first can win the game.
 
【Input】
   There are multiple test cases. Please process till EOF.
   For each test case, the first line contains a postive integer n(n < 105) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer ai(ai < 231) means there are ai beads in the i-th pile.
 
【Output】
   For each test case, if the first player can win the game, ouput "Win" and if he can‘t, ouput "Lose"
 
【Sample Input】
1
1
2
1 1
3
1 2 3
 
【Sample Output】
Win
Lose
Lose
 
【题意】
取石子的游戏:初始时有n堆,每人轮流进行取的过程,每次可以选择某一堆取任意个,然后选择把剩下的部分分成任意数量的两堆。最后一个取完所有东西的人获胜。
【分析】
妈蛋!!!比赛前我根本没听说过Nim博弈好么!!!果然还是题目做的太少T_T,东西了解得太少T_T////////////////////////
看着别人刷刷刷都过了,死活看不明白是怎么回事......哭晕在厕所啊
 
以下是两个博弈论知识的总结帖:
http://blog.csdn.net/u012860063/article/details/21816635
http://blog.csdn.net/chao1983210400/article/details/10284693#
 
 
【F】

Dice

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Problem Description】
   There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A. Similarly, consider b1.b2,b3,b4,b5,b6 to be numbers on specific faces of dice B. It’s guaranteed that all numbers written on dices are integers no smaller than 1 and no more than 6 while ai ≠ aj and bi ≠ bj for all i ≠ j. Specially, sum of numbers on opposite faces may not be 7.
   At the beginning, the two dices may face different(which means there exist some i, ai ≠ bi). Ddy wants to make the two dices look the same from all directions(which means for all i, ai = bi) only by the following four rotation operations.(Please read the picture for more information)
   Now Ddy wants to calculate the minimal steps that he has to take to achieve his goal.
 
【Input】
   There are multiple test cases. Please process till EOF.
   For each case, the first line consists of six integers a1,a2,a3,a4,a5,a6, representing the numbers on dice A.
   The second line consists of six integers b1,b2,b3,b4,b5,b6, representing the numbers on dice B.
 
【Output】
   For each test case, print a line with a number representing the answer. If there’s no way to make two dices exactly the same, output -1.
 
【Sample Input】
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 5 6 4 3
1 2 3 4 5 6
1 4 2 5 3 6
 
【Sample Output】
0
3
-1
 
【】

The 2014 ACMICPC Asia Regional Xian Online