这个题目的突破口就是固定最短长度,然后以二进制的形式分层;

最后把需要的曾连起来;

#include<cstdio>
#include<cstring>
#define maxn 105
using namespace std; bool map[maxn][maxn]; void link(int x,int y)
{
map[x][y]=;
map[y][x]=;
} void pre()
{
link(,);
link(,);
link(,);
for(int i=; i<; i+=)
{
link(i,i+);
link(i,i+);
link(i+,i+);
link(i+,i+);
}
for(int i=; i<; i++)
link(i,i+);
} void solve(int k)
{
for(int i=; i<=; i++)
{
if(<<i&k)
{
link(*i+,+i);
link(*i+,+i);
}
}
if(k&)link(,);
printf("100\n");
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
if(map[i][j])
putchar('Y');
else putchar('N');
}
puts("");
}
} int main()
{
pre();
int k;
scanf("%d",&k);
solve(k);
return ;
}

codeforces 388B Fox and Minimal path的更多相关文章

  1. Codeforces Round #228 (Div. 1) 388B Fox and Minimal path

    链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到2的最短路的图. [分析] 由于是要自己构造图,当 ...

  2. Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造

    B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...

  3. codeforces 389 D. Fox and Minimal path(构造+思维)

    题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...

  4. CF #228 div1 B. Fox and Minimal path

    题目链接:http://codeforces.com/problemset/problem/388/B 大意是用不超过1000个点构造一张边权为1的无向图,使得点1到点2的最短路的个数为给定值k,其中 ...

  5. Educational Codeforces Round 25 E. Minimal Labels&&hdu1258

    这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...

  6. CodeForces 388A Fox and Box Accumulation (模拟)

    A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...

  7. CodeForces - 512B Fox And Jumping[map优化dp]

    B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces 388C Fox and Card Game (贪心博弈)

    Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...

  9. codeforces 510B. Fox And Two Dots 解题报告

    题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...

随机推荐

  1. 关于Eclipse插件开发(一)

    plugin.xml是插件和Eclipse内核的接口,Eclipse就像一所大宅子.它的外墙(plugin.xml)有很多门(扩展点), 要熟练进入这座大宅子,就得先搞清楚它有那些门(扩展点). 插件 ...

  2. asp.net 编写验证码

    首先准备一个类来实现对验证码的绘制功能. createcode.cs using System; using System.Collections.Generic; using System.Linq ...

  3. Ehcache - hello world

    Key Classes CacheManager The CacheManager class is used to manage caches. Creation of, access to, an ...

  4. ORM中去除反射,添加Expression

    之前接触了别人的ORM框架,感觉牛掰到不行,然后试着自己来写自己的ORM. 最初从园子里找到其他人写的反射的例子: List<PropertyInfo> pis = typeof(T).G ...

  5. Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17

    操作环境 操作系统:Mac Os Lion 虚拟主机:VMware Fusion 虚拟系统:Centos 5.5+ 操作用户:Root 实现目的:搭建LNMP环境. 安装依赖库和开发环境 #依赖库和开 ...

  6. OC1_汉字拼音转换 练习

    // // WordManager.h // OC1_汉字拼音转换 // // Created by zhangxueming on 15/4/27. // Copyright (c) 2015年 z ...

  7. Dubbo在Spring和Spring Boot中的使用

    一.在Spring中使用Dubbo 1.Maven依赖 <dependency> <groupId>com.alibaba</groupId> <artifa ...

  8. 九度OJ 1410 垒积木 -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1410 题目描述: 给你一些长方体的积木,问按以下规则能最多垒几个积木. 1 一个积木上面最多只能垒另一个积木. 2 ...

  9. 初识XML及简单工厂运用--网络电视精灵

    网络电视精灵 任务描述 1. 解析XML文件中的数据 三个简单的xml文件; <?xml version="1.0" encoding="utf-8" ? ...

  10. day19 数据库的初步认识

    一:数据库的概念 数据库:一个用于储存数据并可以对之进行管理和使用的软件系统. sql:struct(结构)  query(查询)  language(语言) 结构化查询语言: 其实是一种国际化语言标 ...