SGU 461 Wiki Lists dfs
不难的题,不过蛮有意思的dfs
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
//#define OPEN_FILE
using namespace std;
const char step[][][] = { "<ul>", "</ul>", "<ol>", "</ol>", "<li>", "</li>" };
char s[][];
int m; void display(char ch, int f, int pos){
if (pos != && !f){
printf("%s\n", step[][]);
}
if (ch == '*'){
if (f){
printf("%s\n", step[][]);
}
else{
printf("%s\n", step[][]);
}
}
else{
if (f){
printf("%s\n", step[][]);
}
else{
printf("%s\n", step[][]);
}
}
if (pos != && f){
printf("%s\n", step[][]);
}
}
void dfs(int p, int q, int pos){
while (p <= q){
if (s[p][pos] != '#' && s[p][pos] != '*'){
if (pos == ){
printf("%s\n", s[p]);
}
else{
printf("%s\n%s\n%s\n", step[][], s[p] + pos, step[][]);
}
p++;
continue;
}
int i;
bool flag = false;
for (i = p + ; i <= q; i++){
if (s[i][pos] == s[p][pos]){
flag = true;
}
else{
break;
}
}
i--;
if (flag == true){
display(s[p][pos], , pos);
dfs(p, i, pos + );
display(s[p][pos], , pos);
p = i + ;
}
else{
if (pos == ){
printf("%s\n", s[p]);
}
else{
printf("%s\n%s\n%s\n", step[][], s[p] + pos, step[][]);
}
p++;
}
}
}
int main()
{
#ifdef OPEN_FILE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // OPEN_FILE
m = ;
while (~scanf("%s", s[m])){
m++;
}
m--;
dfs(, m, );
//printf("%d\n", m);
}
SGU 461 Wiki Lists dfs的更多相关文章
- itemscope itemtype="http://schema.org/AggregateRating"
Review Canonical URL: http://schema.org/Review Thing > CreativeWork > Review A review of an it ...
- sgu 125 Shtirlits dfs 难度:0
125. Shtirlits time limit per test: 0.25 sec. memory limit per test: 4096 KB There is a checkered fi ...
- sgu 321 The Spy Network (dfs+贪心)
321. The Spy Network Time limit per test: 0.5 second(s)Memory limit: 65536 kilobytes input: standard ...
- SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operati ...
- 深度优先搜索(DFS)
定义: (维基百科:https://en.wikipedia.org/wiki/Depth-first_search) 深度优先搜索算法(Depth-First-Search),是搜索算法的一种.是沿 ...
- [转]http://lua-users.org/wiki/LpegTutorial
Simple Matching LPeg is a powerful notation for matching text data, which is more capable than Lua s ...
- (转)The AlphaGo Replication Wiki
The AlphaGo Replication Wiki 摘自:https://github.com/Rochester-NRT/RocAlphaGo/wiki/01.-Home Contents : ...
- 树形DP求树的重心 --SGU 134
令一个点的属性值为:去除这个点以及与这个点相连的所有边后得到的连通分量的节点数的最大值. 则树的重心定义为:一个点,这个点的属性值在所有点中是最小的. SGU 134 即要找出所有的重心,并且找出重心 ...
- Codeforces Round #374 (Div. 2) A B C D 水 模拟 dp+dfs 优先队列
A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...
随机推荐
- Linux学习02--Linux一切皆文件
Linux学习第二部 Linux一切皆对象 啊啊啊啊啊,今天被学妹说太直了,嘤嘤嘤. 学习linux两三天了,前期感觉并不难,只是命令多,多记记多敲一敲就能都记住了.希望自己能够坚持下去吧! 下面是根 ...
- parted 4T磁盘
parted /dev/vdg mklabel gpt mkpart primary ext4 0% 100%
- 紫书 习题8-11 UVa 1615 (区间选点问题)
这个点就是贪心策略中的区间选点问题. 把右端点从大到小排序, 左端点从小到大排序. 每次取区间右端点就可以了, 到不能覆盖的时候就ans++, 重新取点 ps:这道题不考虑精度也可以过 要着重复习一下 ...
- Jedis无法连接centOS7上的redis
通过查看资料无法连接基本是两个原因: 1)redis.conf中的bind配置,bind的默认是 127.0.0.1 只可本机访问,我们改为 bind 0.0.0.0 即所有地址均可访问. 2)cen ...
- Linux split 命令用法详解 - 切割文件[转]
功能说明:切割文件.语 法:split [--help][--version][-<行数>][-b <字节>][-C <字节>][-l <行数>][要切 ...
- 架构设计--用户端全http參数接口具体说明v1
1. 用户端全http參数接口具体说明v1.doc 1 2. change histor 1 3. 接口通用參数说明 1 4. 函数注冊接口(规划中) 3 5. 用户权限模块 3 5.1. 用户注冊接 ...
- 我是怎么利用微信做兼职月入1W的
物价上涨.导致非常多人都感觉如今的收入入不敷出,有的是迫于生活压力.有的是为了提高生活质量,等等都想好好利用业余时间来做点兼职,当然我也不例外.正好笔者在微信刚推出一段时间的时候利用微信来做点兼职赚点 ...
- MFC中CFileDialog使用方法
用CFileDialog选择了一个文件后,使用FILE::fopen打开文件错误,使用 的是相对地址.和王工调试了半天,怎么跟踪也没发现错误,原来如此. .... .. . . CFileDialog ...
- uva_11997,K Smallest Sums优先队列
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #inclu ...
- 37.创建自定义的指令的限制使用 通过restrict 设置
转自:https://www.cnblogs.com/best/tag/Angular/ 1. 元素名 <runoob-directive></runoob-directive> ...