题目连接:http://codeforces.com/problemset/problem/656/E

愚人节专场的E,整个其实就是个Floyd算法,但是要求代码中不能包含

define
do
for
foreach
while
repeat
until
if
then
else
elif
elsif
elseif
case
switch

这些关键词。

如果不考虑屏蔽define,很容易想到将代码中用到的关键词全部define成其它不在列表中的词。但是define的时候还是得要写出原来的关键词,况且define也被屏蔽了,有一种方法是利用\将代码分行。

于是C++代码解决这道问题就成了如下所示

 #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <ctime>
#include <set>
using namespace std;
const int N=;
#def\
ine foo fo\
r
int g[N][N];
int dis[N][N];
void floyd(int n) {
memcpy(dis,g,sizeof g);
foo (int k=; k<=n; k++){
foo (int i=; i<=n; i++){
foo (int j=; j<=n; j++) {
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
}
}
}
int main () {
int n;
cin>>n;
foo (int i=;i<=n;i++) {
foo (int j=;j<=n;j++) {
cin>>g[i][j];
}
}
floyd(n);
int ret=;
foo (int i=;i<=n;i++) {
foo (int j=;j<=n;j++) {
ret=max(ret,dis[i][j]);
}
}
cout<<ret<<endl;
return ;
}

其实也可以直接写一个程序,生成代码(IO以及Floyd),但是没有上面的用\分行显得雅观。

除了C++也有很多语言也可以有办法做此题。还看到有人用PHP的解码来做,可惜我不懂PHP。

CF #April Fools Day Contest 2016 E Out of Controls的更多相关文章

  1. April Fools Day Contest 2016 E. Out of Controls

    E. Out of Controls 题目连接: http://www.codeforces.com/contest/656/problem/E Description You are given a ...

  2. 坑爹CF April Fools Day Contest题解

    H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...

  3. April Fools Day Contest 2016 D. Rosetta Problem

    D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...

  4. April Fools Day Contest 2016 G. You're a Professional

    G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...

  5. April Fools Day Contest 2016 F. Ace It!

    F. Ace It! 题目连接: http://www.codeforces.com/contest/656/problem/F Description Input The only line of ...

  6. April Fools Day Contest 2016 C. Without Text 信号与系统

    C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...

  7. April Fools Day Contest 2016 B. Scrambled

    B. Scrambled 题目连接: http://www.codeforces.com/contest/656/problem/B Description Btoh yuo adn yuor roo ...

  8. April Fools Day Contest 2016 A. Da Vinci Powers

    A. Da Vinci Powers 题目连接: http://www.codeforces.com/contest/656/problem/A Description The input conta ...

  9. April Fools Day Contest 2014

    April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...

随机推荐

  1. 【杂】poj2482 Stars in Your Windows 题面的翻译

    原地址:http://poj.org/problem?id=2482 神题,被誉为最浪漫的题目,一位acmer以自己独特的方式写下的殷殷情语 你窗前的星星 纵时光飞逝如梭,也我对你的回忆也永不黯然.从 ...

  2. Eclipse:The selection cannot be launched,and there are no recent launches

    刚刚装上eclipse,于是就想写个Java程序来试试.结果写好之后不管是点击 run  还是  debug 结果都会弹出一个窗口,内容为: The selection cannot be launc ...

  3. Vue基本入门

    介绍 1.Vue.js是什么? Vue.js(读音:/vju:/,类似于view)是一套构建用户界面的渐进式框架,与其他重量级框架不同的是,Vue采用的是自底向上增量开发的设计. Vue的核心库只关注 ...

  4. 2659: [Beijing wc2012]算不出的算式

    2659: [Beijing wc2012]算不出的算式 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 757  Solved: 425[Submit] ...

  5. 关于<context:property-placeholder>的一个有趣现象

    转:http://stamen.iteye.com/blog/1926166 先来看下A和B两个模块 A模块和B模块都分别拥有自己的Spring XML配置,并分别拥有自己的配置文件: A模块 A模块 ...

  6. windows系统解决github.com访问超时

    当github无法访问时,可以尝试在hosts文件中添加下面的内容 windows:c:\windows\system32\drivers\etc 192.30.252.131 https://git ...

  7. css——样式表分类,选择器

    一,样式表分类 (1)内联样式[优先级最高][常用][代码重复使用性最差] (当特殊的样式需要应用到个别元素时,就可以使用内联样式. 使用内联样式的方法是在相关的标签中使用样式属性.样式属性可以包含任 ...

  8. 走入PHP-初次见面

    FROM:实验楼 Linux启动WEB服务器: $ sudo service apache2 start 新建并打开test.php文件: $ sudo gvim /path/test.php PHP ...

  9. Sublime Text3 编辑器我的最爱

    简介 Sublime Text 3是一个神奇的文本编辑器,适合程序员.作家.它有很多亮点功能,比如多选择.Go Anything.命令面板.多选择可以让你同时编辑多出代码,Got Anything 像 ...

  10. 浅谈对java中传参问题的理解

    之前用的c/c++比较多,在c/c++中对于传参类型,无外乎就是传值.传引用.传指针这几种.但在java中,由于没有指针类型,其传参的方式也发生了相应的变化.在网上找了找,按我之前的理解,java中传 ...