codeforces 388B Fox and Minimal path
这个题目的突破口就是固定最短长度,然后以二进制的形式分层;
最后把需要的曾连起来;
#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的更多相关文章
- Codeforces Round #228 (Div. 1) 388B Fox and Minimal path
链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到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 ...
- codeforces 389 D. Fox and Minimal path(构造+思维)
题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...
- CF #228 div1 B. Fox and Minimal path
题目链接:http://codeforces.com/problemset/problem/388/B 大意是用不超过1000个点构造一张边权为1的无向图,使得点1到点2的最短路的个数为给定值k,其中 ...
- Educational Codeforces Round 25 E. Minimal Labels&&hdu1258
这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...
- 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 ...
- 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 ...
- 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 ...
- codeforces 510B. Fox And Two Dots 解题报告
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
随机推荐
- 浅谈在实验室的一个作品---8x8x8光立方
在实验室学习51单片机之后,觉得是得做点东西,提高一下动手能力,光立方就成了自己忙碌的目标.买了1000个灯,准备好之后就开始了为期一周的焊接, 一周之后就是这个样子啦.... 之后就进行了电路板的焊 ...
- 【Objective-C】4-空指针和野指针
一.什么是空指针和野指针 1.空指针 1> 没有存储任何内存地址的指针就称为空指针(NULL指针) 2> 空指针就是被赋值为0的指针,在没有被具体初始化之前,其值为0. 下面两个都是空指针 ...
- Android沉浸式状态栏实现
Step1:状态栏与导航栏半透明化 方法一:继承主题特定主题 在Android API 19以上可以使用****.TranslucentDecor***有关的主题,自带相应半透明效果 例如: < ...
- IO流详解之代码详解
前面呢已经发了一些理解,整理了注释,整体来说IO这里难度不是很大,代码呢没有详细敲,只写了一个大概总结的内容如下: /** 一切皆文件:文件是所有操作系统保存数据和处理逻辑的唯一方式:不管是.exe, ...
- asp:保留两位小数:
<%=Formatnumber(-6665.8999,3,-1,-1,0)%>(6665.900)一个例子用到了函数Formatnumber()的所有参数:第一个参数(-6665.8999 ...
- Strut2文件下载
Struts2控制文件下载,可以在文件下载之前做一些操作.这里就以权限控制为例,简单实现一下Struts2的文件下载. 一.Struts2文件下载的Action配置,是提供了一个能返回InputStr ...
- CAF(C++ actor framework)使用随笔(projection 用法)(一)
最近干活在写毕设,用到了CAF,看了文档,发现了一些小坑,自己摸索写点随笔.(CAF的github网站 https://github.com/actor-framework/actor-framewo ...
- TCP传输小数据包效率问题(译自MSDN)
TCP传输小数据包效率问题(译自MSDN) http://www.ftpff.com/blog/?q=node/16 摘要:当使用TCP传输小型数据包时,程序的设计是相当重要的.如果在设计方案中不对T ...
- Xml通用操作类
using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Xml ...
- win 8.1 网卡
win 8.1无线网卡是好的,驱动正常.但是搜索不到附近网络