不难的题,不过蛮有意思的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. 洛谷 P1052 过河 (离散化+dp)

    dp非常好想, f[i] = min(f[i-len] + stone[i]) s <= len <= t 然后因为L非常大,所以我就不知道该怎么搞了 我看到m只有100,而L有1e9,我 ...

  2. POJ3370&amp;HDU1808 Halloween treats【鸽巢原理】

    题目链接: id=3370">http://poj.org/problem?id=3370 http://acm.hdu.edu.cn/showproblem.php?pid=1808 ...

  3. Java IO(二) 之 InputStream

    源代码均以JDK1.8作为參考 前言: InputStream实现了两个接口Closeable和AutoCloseable: Closeable:JDK1.5中引入,Closeable接口中仅仅有一个 ...

  4. 管理ONS(Oracle Notification Service)

    Onsctl Onsctl这个命令是用来管理ONS(Oracle Notification Service)是OracleClustser实现FAN Event Push模型的基础. Oracle N ...

  5. 【剑指Offer面试题】 九度OJ1371:最小的K个数

    题目链接地址: http://ac.jobdu.com/problem.php?pid=1371 题目1371:最小的K个数 时间限制:1 秒内存限制:32 兆特殊判题:否提交:5938解决:1265 ...

  6. 【CTO辩论会】移动开发人员忠于技术or 背离技术

    第一期CTO辩论会结束后,大家在微信群中讨论,学什么编程语言好.有位官人直呼"劳力者治于人,苦差,不学也罢". 在IT.科技变革世界的今天,移动开发人员成为一个很时髦的工种. 就连 ...

  7. 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记3 Xcode、Auto Layout及MVC

    继续上一话中的计算器Demo.上一话讲到类必须被初始化.类中的属性也必须被初始化,所以你不能仅仅声明而不给它一个处置,那么问题来了,我们从storyboard中拖拽的@IBOutlet为什么仅仅有声明 ...

  8. Java多线程理解:线程安全的集合对象

    1.概念介绍 线程安全就是多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用.不会出现数据不一致或者数据污染. 线程不安全就 ...

  9. 13.MongoDB 连接命令格式

    转自:https://www.linuxidc.com/Linux/2016-03/129456.htm 使用用户 admin 使用密码 123456 连接到本地的 MongoDB 服务上.输出结果如 ...

  10. 35.angularJS的ng-repeat指令

    转自:https://www.cnblogs.com/best/tag/Angular/ 1. <html> <head> <meta charset="utf ...