CF #April Fools Day Contest 2016 E Out of Controls
题目连接: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的更多相关文章
- 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 ...
- 坑爹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 ...
- April Fools Day Contest 2016 D. Rosetta Problem
D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...
- 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 ...
- 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 ...
- April Fools Day Contest 2016 C. Without Text 信号与系统
C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...
- April Fools Day Contest 2016 B. Scrambled
B. Scrambled 题目连接: http://www.codeforces.com/contest/656/problem/B Description Btoh yuo adn yuor roo ...
- 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 ...
- April Fools Day Contest 2014
April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...
随机推荐
- 非服务器的定期校正时间 Anacron
与服务器不同,编程和办公用计算机不是连续24小时运行的.开关机的时间不固定,类似较时这样的任务无法保证运行. 对于这类机器,可以考虑使用 Anacron 进行设置. 在 Archlinux 中, An ...
- C# 在PDF中创建和填充域
C# 在PDF中创建和填充域 众所周知,PDF文档通常是不能编辑和修改的.如果用户需要在PDF文档中签名或者填写其他内容时,就需要PDF文档中有可编辑的域.开发者也经常会遇到将数据以编程的方式填充到P ...
- Maven项目搭建(一):Maven初体验
今天给大家介绍一个项目管理和综合工具:Maven. Maven: maven读作 ['meivin],本意是指可以被信任的领域专家,致力于传播知识(来自于http://en.wikipedia.org ...
- JavaWeb之Filter、Listener
昨天和大家介绍了一下JSON的用法,其实JSON中主要是用来和数据库交互数据的.今天给大家讲解的是Filter和Listener的用法. 一.Listenner监听器 1.1.定义 Javaweb中的 ...
- SSH登录与增删改查demo详解+源代码
点击下载,测试绝对可用SSH整合框架登录加增删改查demo 下载地址:http://download.csdn.net/detail/qq_33599520/9784679 一.框架概述 spri ...
- mac下常用软件整理
1.非常好用的压缩管理软件(免费版):RAR Extrator Free 解压的中文不会产生乱码: 2.记笔记用的:有道笔记.Evernote 3.SVN管理软件:ConerStone 4.非常给力 ...
- 搭建高可用mongo集群3.4版本
搭建高可用mongo集群3.4版本 说在开始之前:在搭建这个环境之前,已经有了一个师兄搭好的环境,虽然一样很棒,但是没有经过自己的手出来的东西,还是不属于自己,所以摸索着自己搭建一个吧,好巧不巧的是, ...
- [译]Selenium Python文档:四、元素定位
要定位一个页面中的元素有多中策略和方法.你可以根据实际情况选择其中最为合适的.Selenium为定位页面元素提供了下面的这些方法: find_element_by_id(使用id) find_elem ...
- JS把命名空间传递给模块形式
//方法依赖 jquery 或者其他 有扩展方法 extend() 类库 例如: underscore.js 链接地址 http://underscorejs.org var app = {}; ( ...
- 多线程爬坑之路-J.U.C.atomic包下的AtomicInteger,AtomicLong等类的源码解析
Atomic原子类:为基本类型的封装类Boolean,Integer,Long,对象引用等提供原子操作. 一.Atomic包下的所有类如下表: 类摘要 AtomicBoolean 可以用原子方式更新的 ...