不难的题,不过蛮有意思的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的更多相关文章

  1. itemscope itemtype="http://schema.org/AggregateRating"

    Review Canonical URL: http://schema.org/Review Thing > CreativeWork > Review A review of an it ...

  2. 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 ...

  3. sgu 321 The Spy Network (dfs+贪心)

    321. The Spy Network Time limit per test: 0.5 second(s)Memory limit: 65536 kilobytes input: standard ...

  4. 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 ...

  5. 深度优先搜索(DFS)

    定义: (维基百科:https://en.wikipedia.org/wiki/Depth-first_search) 深度优先搜索算法(Depth-First-Search),是搜索算法的一种.是沿 ...

  6. [转]http://lua-users.org/wiki/LpegTutorial

    Simple Matching LPeg is a powerful notation for matching text data, which is more capable than Lua s ...

  7. (转)The AlphaGo Replication Wiki

    The AlphaGo Replication Wiki 摘自:https://github.com/Rochester-NRT/RocAlphaGo/wiki/01.-Home Contents : ...

  8. 树形DP求树的重心 --SGU 134

    令一个点的属性值为:去除这个点以及与这个点相连的所有边后得到的连通分量的节点数的最大值. 则树的重心定义为:一个点,这个点的属性值在所有点中是最小的. SGU 134 即要找出所有的重心,并且找出重心 ...

  9. 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 ...

随机推荐

  1. redis搭建与安装

    redis提供五种数据类型:string,hash,list,set及zset(sorted set). 第一部分:安装redis 希望将redis安装到此目录 1 /usr/local/redis ...

  2. [ACM] hdu 4248 A Famous Stone Collector (DP+组合)

    A Famous Stone Collector Problem Description Mr. B loves to play with colorful stones. There are n c ...

  3. android 自己定义dialog并实现失去焦点(背景透明)的功能

    前言:因为在项目中须要用到更新显示动画的需求,所以想到了dialog,自己定义dialog不难.网上教程非常多,可是在实现dialog背景透明的需求时,遇到了一点问题.网上的一些方法在我的机器上并没有 ...

  4. hibernate 或jpa 中使用 AliasToBeanResultTransformer 自定义类型转换ResultTransformer 下划线转驼峰

    jpa中使用 sql查询时,返回结果直接转为实体bean的实现, 需要自定义一个ResultTransformer,如下, import java.util.Arrays; import org.ap ...

  5. hpuoj--校赛--面试难题(区间相交问题)

    问题 F: 感恩节KK专场--面试难题 时间限制: 1 Sec  内存限制: 128 MB 提交: 294  解决: 39 [提交][状态][讨论版] 题目描述 有n个人要来面试学生会XX部门,要求面 ...

  6. numa 和 mysql

    cpu numa结构反应的内存访问速度问题: 在多核cpu的时代引入了cpu的numa(非一致内存访问结构): NUMA引入了node的概念,每个物理CPU都被视作一个node,而每个node都有一个 ...

  7. vue打包后js和css、图片不显示,引用的字体找不到问题

    vue打包后js和css.图片不显示,引用的字体找不到问题:图片一般都是背景图片. 一.vue打包出现js和css不显示问题: 1.不使用mode:'history' 2.使用mode:'histor ...

  8. PHPSTORM+Xdebug断点调试代码

    如果没有安装 PHPSTORM 可以参考 phpstorm10安装并汉化 一.下载 XDEBUG 下载地址:https://xdebug.org/download.php 二.如何快速寻找适合自己PH ...

  9. 学习《深度学习入门:基于Python的理论与实现》高清中文版PDF+源代码

    入门神经网络深度学习,推荐学习<深度学习入门:基于Python的理论与实现>,这本书不来虚的,一上来就是手把手教你一步步搭建出一个神经网络,还能把每一步的出处讲明白.理解神经网络,很容易就 ...

  10. subline Text3 插件安装

    --没有解决,换了vscode 安装Package Control 这是必须的步骤,安装任何插件之前需要安装这个 自动安装的方法最方便,只需要在控制台(不是win的控制台,而是subline 的)里粘 ...