题目连接: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. HTM5新手学习的一些日常总结,相互交流和相互学习。

    第一天 一.HTML--网页的源码(超文本标签语言) HTML标签 标签式是HTML最基本单位和最重要的组成. 使<和>扩起来 标签都是闭合的(规范) HTML标签属性 是标签的一部分,用 ...

  2. ArrayList源码剖析

    ArrayList简介 ArrayList是基于数组实现的,是一个动态数组,其容量能自动增长,类似于C语言中的动态申请内存,动态增长内存. ArrayList不是线程安全的,只能用在单线程环境下,多线 ...

  3. Sort List leetcode

    这个题一开始本想用快速排序的,但是想了20分钟都没有头绪,难点在于快速排序的随机访问无法用链表实现,不过如果可以实现快速排序partition函数就可以了,但是这可能比较复杂,于是改用其他排序方法,上 ...

  4. 使用Three.js网页引擎创建酷炫的3D效果的标签墙

    使用Three.js引擎(这是开源的webgl三维引擎,gitgub)进行一个简单应用. 做一个酷炫的3d效果的标签墙(已经放在我的博客首页,大屏幕可见), 去我的博客首页看看实际效果 www.son ...

  5. JavaScript重新介绍

    本文转载自 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/A_re-introduction_to_JavaScript 引言 为什么 ...

  6. NIO(二、Buffer)

    目录 NIO(一.概述) NIO(二.Buffer) Buffer 前文讲了NIO与IO的区别,那么这一章开始讲述NIO下核心类 - Buffer类 上一章就说过,NIO的核心包括三个部分:通道(Ch ...

  7. 防火墙之netfailt、iptables详解

    [TOC] Iptables入门 # 1.iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. netfilter 组件也称为 ...

  8. 关于数组和集合的冒泡排序中容易出现的IndexOutOfBoundsException

    数组只能存错一种相同的数据类型,集合只能存储引用数据类型(用泛型),集合的底层就是一个可变的数组. 数组的冒泡排序: public static void arrayMaxPaiXu(int[] ar ...

  9. css删除线,下划线等

    <style> .p1 { text-decoration:overline; //上划线 } .p2 { text-decoration:line-through; //删除线 }  . ...

  10. React+Node初尝试

    这是第一次写React和Node,选用的是前端Material-ui框架,后端使用的是Express框架,数据库采用的是Mongodb. 项目代码在:GitHub/lilu_movie 这是一个通过从 ...