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 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
随机推荐
- SpringMVC框架
一.SpringMVC工作流程图 DispatcherServlet:Spring提供的前端控制器,所有的请求都有经过它来统一分发.在DispatcherServlet将请求分发给Spring Con ...
- php中的匿名函数(Anonymous functions)和闭包函数(closures)
一:匿名函数 (在php5.3.0 或以上才能使用) php中的匿名函数(Anonymous functions), 也叫闭包函数(closures), 允许指定一个没有名称的函数.最常用的就是回调函 ...
- JavaScript高级程序设计(九):基本概念----函数
一.参数的理解 1.ECMAScript中的参数在内部是用一个数组来表示的.函数接收到的始终是这个数组,而不关心数组中包含多少个参数,即使没有参数也可以. 2.实质上,函数可以通过arguments对 ...
- ###STL学习--迭代器
点击查看Evernote原文. #@author: gr #@date: 2014-08-23 #@email: forgerui@gmail.com STL中的迭代器. ###stl学习 |--迭代 ...
- mybatis关联查询
场景:一个人有多个手机号,一个手机号对应一个人 CREATE TABLE test.mobile ( mid INT NOT NULL auto_increment, tel ), pid INT, ...
- 16_会话技术_Session案例
[购物车中的信息保存] [Book.java] package com.Higgin.shopping; public class Book { private String id; private ...
- [算法] get_lucky_price price
int get_lucky_price(int price, const vector & number) 题意大概是给你一个数price,比如1000,然后有unlucky_num,有{1, ...
- How do I create an installation log?
Quote from: http://www.advancedinstaller.com/user-guide/qa-log.html Windows Installer logging Window ...
- (转)MySql可视化工具MySQL Workbench使用教程
转自:http://www.cnblogs.com/daimage/archive/2012/02/25/2367534.html 1. MySQL Workbench MySQL Workbench ...
- python isinstance 判断各种类型的小细节
1. 基本语法 isinstance(object, classinfo) Return true if the object argument is an instance of the class ...