Codeforces April Fools Day Contest 2014(附官方题解)

2024-06-24 03:32

本文主要是介绍Codeforces April Fools Day Contest 2014(附官方题解),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Codeforces2014年愚人节的坑题。。。但还是感觉挺好玩的。。。

A. The Great Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. Figure out who became the champion.

Input

The input contains two strings of equal length (between 2 and 20 characters, inclusive). Each line describes the actions of one team.

Output

Output "TEAM 1 WINS" if the first team won, "TEAM 2 WINS" if the second team won, and "TIE" if there was a tie.

Sample test(s)
input
[]()[]8<
8<[]()8<
output
TEAM 2 WINS
input
8<8<()
[]8<[]
output
TIE


类似于剪刀石头布

AC代码如下:

#include <cstdio>
#include <cstring>int main() {char a[21], b[21];scanf("%s%s", a, b);int cnt1 = 0, cnt2 = 0;int len = strlen(a);for (int i = 0; i < len; i += 2) {if (a[i] == '8') {if (b[i] == '[') {cnt1++;} else if (b[i] == '(') {cnt2++;}} else if (a[i] == '[') {if (b[i] == '(') {cnt1++;} else if (b[i] == '8') {cnt2++;}} else if (a[i] == '('){if (b[i] == '8') {cnt1++;} else if(b[i] == '[') {cnt2++;}}}if (cnt1 > cnt2) {printf("TEAM 1 WINS\n");} else if (cnt1 < cnt2) {printf("TEAM 2 WINS\n");} else {printf("TIE\n");}return 0;
}

B. Mysterious Language
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language.

Input

This program has only one test (your program doesn't have to read anything).

Output

Output the name of the mysterious language. Note that the name is case-sensitive and might contain digits and special characters.

Sample test(s)
Note

Some scientists disagree on what should be considered as a language and what should be considered as a dialect.


看完AC代码已哭瞎,题中所指的Mysterious Language是Fortran,根本没听说过有木有!。。。

AC代码如下:

       print*, 'FORTRAN 77'END

C. Magnum Opus
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Salve, mi amice.

Et tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.

Rp:

    I Aqua Fortis

    I Aqua Regia

    II Amalgama

    VII Minium

    IV Vitriol

Misce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.

Fac et spera,

Vale,

Nicolas Flamel

Input

The first line of input contains several space-separated integers ai (0 ≤ ai ≤ 100).

Output

Print a single integer.

Sample test(s)
input
2 4 6 8 10
output
1

题目内容是一名炼金术师Nicolas Flamel用拉丁文写的炼制某物质的配方,所以题中给出了要炼制一单位某东西需要五种物质的量分别为I(1)、I(1)、II(2)、VII(7)、IV(4),问最多能制造多少单位的这种物质。

AC代码如下:

#include <cstdio>int main() {int a[5];for (int i = 0; i < 5; ++i) {scanf("%d", &a[i]);}a[2] /= 2;a[3] /= 7;a[4] /= 4;int MIN = a[0];for (int i = 1; i < 5; ++i) {if (MIN > a[i]) {MIN = a[i];}}printf("%d\n", MIN);return 0;
}


D. Big Data
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts:

  • The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.
  • The largest board game tournament consisted of 958 participants playing chapaev.
  • The largest online maths competition consisted of 12766 participants.
  • The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length.
  • While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points.
  • Angel Falls is the highest waterfall. Its greatest single drop measures 807 m.
  • The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m
  • Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons.
  • The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in thetwentieth century.
  • The longest snake held in captivity is over 25 feet long. Its name is Medusa.
  • Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters.
  • Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom.
  • The largest state of USA is Alaska; its area is 663268 square miles
  • Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long.
  • Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water.
  • The most colorful national flag is the one of Turkmenistan, with 106 colors.
Input

The input will contain a single integer between 1 and 16.

Output

Output a single integer.

Sample test(s)
input
1
output
1
input
7
output
0

题的内容和题目完全不沾边,都是吓唬人的。这道题是判断上面的几个说法是否正确,正确输出“1”, 反之输出“0”。

AC代码如下:

#include <cstdio>char s[] = "1001010111001010";
int main() {int n;scanf("%d", &n);printf("%c\n", s[n-1]);return 0;
}

F. 000001
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Input

The input contains a single integer a (1 ≤ a ≤ 64).

Output

Output a single integer.

Sample test(s)
input
2
output
1
input
4
output
2
input
27
output
5
input
42
output
6

题目描述过于简单,唯一的线索就是题目000001。其实000001是oeis网站上第一个数字序列,名为Number of groups of order n,即n阶群数目。只需要打开网站找到A000001序列即可得到本题的答案。

AC代码如下:

#include <cstdio>int a[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267};int main() {int n;scanf("%d", &n);printf("%d\n", a[n-1]);return 0;
}


H. A + B Strikes Back
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try?

Input

The input contains two integers a and b (0 ≤ a, b ≤ 103), separated by a single space.

Output

Output the sum of the given integers.

Sample test(s)
input
5 14
output
19
input
381 492
output
873
又一道神坑题,没窍门,改改输出格式多交几遍就过了,代码Pass。。。



附官方题解:

April Fools Day Contest 2014: editorial


Unfortunately, the most anybody could solve was 7 problems out of 9 total. 1289 participants solved at least one problem — this is less than the last year's numbers, but not bad either. Anyways, the key point is the total quantity of fun the people had!

409A - The Great Game

The Most Intellectually Challenging Game In The World turned out to be the famous rock-paper-scissors. One could deduce this from the examples — ok, the rock () didn't look itself, but paper [] and especially scissors 8< looked really lifelike!

Team competition is organized like this: players are split into pairs, with one player of each team in each pair, and pairs play against each other (the first line of input has "moves" of first team's players, the second line — of second team's players). The team which scores more individual victories wins.

By the way, the game is not so trivial as it looks — there are big tomes written about the strategies, game ethics and organizing clubs and competitions, the tournaments run in many countries, and the largest tournament had over 6500 participants!

409B - Mysterious Language

Attempting to run nearly any code in Mysterious Language resulted in a pack of compilation errors, among them — "Unclassifiable statement at (1)". This pointed to Fortran language immediately, but then the doubts began. There are quite a few Fortrans out there, and even more compilers, so what exactly needs to be printed out? My idea was that the compiler should have been configured to accept only fixed format of Fortran programs, which points to FORTRAN 77 (Fortran 90 and later supported free format, without uppercasing commands and indentation). Judging from the questions and the comments, something went wrong here, and some programs in free format compiled fine... Anyways, the answer is "FORTRAN 77".

409C - Magnum Opus

Magnum Opus is an alchemy name for the process of philosophical stone creation. This (and also the signature "Nicolas Flammel") hints that the problem describes a recipe of the philosophical stone, and our task is to create it. If we recognize the statement as a text in Latin (although there were attempts to interpret is as Italian) and go to Google Translate for help, we can enjoy the literary beauty and deep irony of the letter, in which a mature alchemist shares the secrets of trade with his younger colleague. Or you can neglect the twists and fast forward to solving the problem, if you notice that the input has 5 numbers, and the recipe contains 5 ingredients in given proportion (proportions are given with easily recognizable Roman numbers before the names of ingredients).

Overall the problem asked how much of philosophical stone we can create, if we have given quantities of ingredients and a smoothly running manufacturing procedure. The answer is min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4).

409D - Big Data

A lot of facts with big numbers is not yet big data. Especially if half of them are wrong! The biggest board games tournament had 43 thousand chess players, the math competition — over a million participants, and Colonel Meow, while a gorgeous cat (you can enjoy the photos at Guinness World Records site ), still doesn't feature a meter-long fur!

The problem asked you to figure out the truth of the given facts, and print 1 or 0 depending on whether i-th fact is true or not-so-true.

409E - Dome

This geometry problem (a joke itself :-) ) was described with a single picture: a hemisphere inscribed in a pyramid. An extra kick is that the problem is kind of inverse problem — you are not given the pyramid and asked to find the radius of a hemisphere, but rather given the hemisphere and asked to build a pyramid around it. Fortunately, pyramid parameters height h and base side length a took only integer values from 1 to 10. The easiest way to tackle this was to try all possible pairs of a and h, calculate all radii (as height in a right-angled triangle with sides h and a/2) and check whether the resulting radius is close to the given one. Note that some radii can be obtained from several pyramids.

409F - 000001

Imagine, initially I wanted to put this problem first, and less than 30 people solved it :-) This is a problem writer's dream — a problem without a statement. Given 4 examples, it's rather tricky to guess an int -> int function for 64 input values. More or less evident theories like "the smallest power of 2 greater than or equal to a" turn out to be wrong (the contest discussion has several more elegant but totally wrong ideas).

Two heuristics* help: 1) even if a problem has no statement, it has a name, and 2) any strange function int -> int can be looked for in Online Encyclopedia of Integer Sequences. Combine them, and you'll get a sequence http://oeis.org/A000001. To solve the problem you don't even have to figure out what "groups of order n" are — the first 64 elements of the sequence are given in the article about it.

  • Note that using a third heuristic (even if a problem has no statement, it has the constraints) is misleading in this case.
409G - On a plane

This problem was written by Skiminok; I'm quite a trickster myself, but I wouldn't have dreamed of giving the statement in samples. And not just giving it; the points from each sample had to be plotted on a 2D plane to get a picture like this


and read from it the statement: 5 + AVG Y (each sample represented one letter).

409H - A + B Strikes Back

This problem caused plenty of emotions and questions "how can it be, I had correct answers for the pretests, and the submission fails the very first test?". See, today is April 1st, and even the checker might feel a bit playful today. For example, it might refuse to accept the solution, and it will require some persuasion for it to stop being naughty. The authors' idea was to reject the first five attempts on the problem right away, and to start actually checking the submissions only starting with the 6th attempt. I do hope that it looked like this from participants' point of view :-)

409I - Feed the Golorp

This problem was contributed by kit1980.

Golorp's name (have anyone noticed that "golorp" is "prolog" spelled backwards?) is an expression in Prolog. The jaws (left part up to ":-") contains the list of variables (possibly with repetitions) separated by arithmetic characters. The characters are just separators and have no deep meaning, they can be replaced with commas. The stomach (right part after ":-") lists the inequalities that must hold for the variables from the jaws.

The task is to find lexicographically smallest set of variable values which satisfy the constraints. In fact, you have to perform topological sorting. The easiest way is to iterate infinitely through the inequalities, find the ones which are not satisfied yet and increase the value of the variable which must be greater than the other one in it. As soon as one of the variables grows to be 10, the answer is false. Otherwise we will stop when all inequalities are satisfied. With the given constraints the solution is fast enough.


这篇关于Codeforces April Fools Day Contest 2014(附官方题解)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1089049

相关文章

活用c4d官方开发文档查询代码

当你问AI助手比如豆包,如何用python禁止掉xpresso标签时候,它会提示到 这时候要用到两个东西。https://developers.maxon.net/论坛搜索和开发文档 比如这里我就在官方找到正确的id描述 然后我就把参数标签换过来

day-51 合并零之间的节点

思路 直接遍历链表即可,遇到val=0跳过,val非零则加在一起,最后返回即可 解题过程 返回链表可以有头结点,方便插入,返回head.next Code /*** Definition for singly-linked list.* public class ListNode {* int val;* ListNode next;* ListNode() {}*

Codeforces Round #240 (Div. 2) E分治算法探究1

Codeforces Round #240 (Div. 2) E  http://codeforces.com/contest/415/problem/E 2^n个数,每次操作将其分成2^q份,对于每一份内部的数进行翻转(逆序),每次操作完后输出操作后新序列的逆序对数。 图一:  划分子问题。 图二: 分而治之,=>  合并 。 图三: 回溯:

ZOJ Monthly, August 2014小记

最近太忙太忙,只能抽时间写几道简单题。不过我倒是明白要想水平提高不看题解是最好的了。 A  我只能死找规律了,无法证明 int a[50002][2] ;vector< vector<int> > gmax , gmin ;int main(){int n , i , j , k , cmax , cmin ;while(cin>>n){/* g

Codeforces Round #261 (Div. 2)小记

A  XX注意最后输出满足条件,我也不知道为什么写的这么长。 #define X first#define Y secondvector<pair<int , int> > a ;int can(pair<int , int> c){return -1000 <= c.X && c.X <= 1000&& -1000 <= c.Y && c.Y <= 1000 ;}int m

Codeforces Beta Round #47 C凸包 (最终写法)

题意慢慢看。 typedef long long LL ;int cmp(double x){if(fabs(x) < 1e-8) return 0 ;return x > 0 ? 1 : -1 ;}struct point{double x , y ;point(){}point(double _x , double _y):x(_x) , y(_y){}point op

Codeforces Round #113 (Div. 2) B 判断多边形是否在凸包内

题目点击打开链接 凸多边形A, 多边形B, 判断B是否严格在A内。  注意AB有重点 。  将A,B上的点合在一起求凸包,如果凸包上的点是B的某个点,则B肯定不在A内。 或者说B上的某点在凸包的边上则也说明B不严格在A里面。 这个处理有个巧妙的方法,只需在求凸包的时候, <=  改成< 也就是说凸包一条边上的所有点都重复点都记录在凸包里面了。 另外不能去重点。 int

2014 Multi-University Training Contest 8小记

1002 计算几何 最大的速度才可能拥有无限的面积。 最大的速度的点 求凸包, 凸包上的点( 注意不是端点 ) 才拥有无限的面积 注意 :  凸包上如果有重点则不满足。 另外最大的速度为0也不行的。 int cmp(double x){if(fabs(x) < 1e-8) return 0 ;if(x > 0) return 1 ;return -1 ;}struct poin

2014 Multi-University Training Contest 7小记

1003   数学 , 先暴力再解方程。 在b进制下是个2 , 3 位数的 大概是10000进制以上 。这部分解方程 2-10000 直接暴力 typedef long long LL ;LL n ;int ok(int b){LL m = n ;int c ;while(m){c = m % b ;if(c == 3 || c == 4 || c == 5 ||

2014 Multi-University Training Contest 6小记

1003  贪心 对于111...10....000 这样的序列,  a 为1的个数,b为0的个数,易得当 x= a / (a + b) 时 f最小。 讲串分成若干段  1..10..0   ,  1..10..0 ,  要满足x非递减 。  对于 xi > xi+1  这样的合并 即可。 const int maxn = 100008 ;struct Node{int