题目连接: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. KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub-loader

    koahub loader Installation $ npm install koahub-loader Use with koa  // 1.model loader   var model = ...

  2. 1671: [Usaco2005 Dec]Knights of Ni 骑士

    1671: [Usaco2005 Dec]Knights of Ni 骑士 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 254  Solved: 163 ...

  3. 复杂SQL代码实例

    DECLARE @begin DATETIME,@end DATETIME,@shanghutype INT, @beginshanghuarea BIGINT ,@endshanghuarea bi ...

  4. 在Ubuntu Linux下制作Windows 启动安装 USB盘

    最近想 ,在Ubuntu上刻录个windows的安装U盘,在网上看了些资料,不过好多都说的很模糊,于是乎,我走了不少弯路.这里记录下来,希望了帮到大家. 首先你的有个USB吧,这里我们假定USB在ub ...

  5. 嵌入式ARM开发环境搭建

    1. 安装,配置,启动FTP服务 安装FTP: sudo apt-get install vsftpd 修改vsftpd的配置文件/etc/vsftpd.conf,将下面两行的'#'去掉#local_ ...

  6. css 层叠式样式表

    内联样式:样式优先级最高的 <div style="width:100px;height:100px;"></div> style=“” 用冒号和分号 wi ...

  7. querySlector

    在传统的 JavaScript 开发中,查找 DOM 往往是开发人员遇到的第一个头疼的问题,原生的 JavaScript 所提供的 DOM 选择方法并不多,仅仅局限于通过 tag, name, id ...

  8. Tcl与Design Compiler (三)——DC综合的流程

    本文属于原创手打(有参考文献),如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/  ,作者:IC_learner 1.基本流程概述 首先 ...

  9. 分解机(Factorization Machines)推荐算法原理

    对于分解机(Factorization Machines,FM)推荐算法原理,本来想自己单独写一篇的.但是看到peghoty写的FM不光简单易懂,而且排版也非常好,因此转载过来,自己就不再单独写FM了 ...

  10. bootstrap使用模板

    Bootstrap下载地址: - https://github.com/twbs/bootstrap/releases/download/v3.3.6/bootstrap-3.3.6-dist.zip ...