题目连接: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. tesseract ocr文字识别

    一.环境搭建 (基于VS2010) 1.下载安装 tesseract-ocr-setup-3.02.02.exe 安装包 ,安装时候最好是在FQ的情况下安装.(安装一点要勾选 Tesseract de ...

  2. WINFROM 无边框窗体的移动和改变大小

    因为去掉了边框  移动和调整大小都用不了了,可以调用WIN32的API来实现 1.定义必须常量 ; ; ; ; ; ; const int Guying_HTBOTTOMLEFT = 0x10; ; ...

  3. Unity 3D Framework Designing(6)——设计动态数据集合ObservableList

    什么是 『动态数据集合』 ?简而言之,就是当集合添加.删除项目或者重置时,能提供一种通知机制,告诉UI动态更新界面.有经验的程序员脑海里迸出的第一个词就是 ObservableCollection.没 ...

  4. bootstrap file input 官方文档翻译

    file Input官方文档 中文翻译 file input 特性 1.这个插件会把简单的html文件变成一个更好用的文件选择输入控件,通过一个html的文件输入框,能兼容那些不支持jquery或js ...

  5. Tcl与Design Compiler (十二)——综合后处理

    本文如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/  ,作者:IC_learner 概述 前面也讲了一些综合后的需要进行的一些工作,这 ...

  6. 使用SevenZipSharp出现“Can not load 7-zip library or internal COM error! Message: DLL file does not exist.”的解决方案

    如果你是从nuget上下载安装的SevenZipSharp库,当你写好相应代码,兴冲冲的启动程序进行测试时,以下画面会让你受到当头一棒: 究其原因,是因为SevenZipSharp只是native 7 ...

  7. 老李分享:接电话扩展之uiautomator 1

    老李分享:接电话扩展之uiautomator   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq ...

  8. [C#] 使用 StackExchange.Redis 封装属于自己的 Helper

    使用 StackExchange.Redis 封装属于自己的 Helper 目录 核心类 ConnectionMultiplexer 字符串(String) 哈希(Hash) 列表(List) 有序集 ...

  9. ajax 第四步

    Ajax和XMLHttpRequest详述 (2011-12-10 16:40:23) 转载▼ 标签: ajax xmlhttprequest 分类: Web Ajax:Asynchronous Ja ...

  10. Android完全退出activity

    在Android中,如果想退出Android程序,一般都是调用finish().System.exit(0).android.os.Process.killProcess(android.os.Pro ...