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 ...
随机推荐
- 【mysql】新增、修改、删除、查询 语法讲义
一.DML - 数据操作语言 INSERT - 实现数据表数据的新增 UPDATE - 实现数据表数据的修改 DELETE - 实现数据表数据的删除 二.INSERT 语法: insert into ...
- docker mysql 文件挂载和MySQL字符集设置
原文:docker mysql 文件挂载和MySQL字符集设置 docker run -p 3306:3306 --name mysql -v /usr/local/mysql/my.cnf:/etc ...
- Windows下安装Linux虚拟机的用途和好处
Windows一般是办公界面,主要做代码编辑查看,资料查找,还有发邮件,也可以用Windows下的其他的有用软件,Linux主要作为编译工具,基本上开发都是在Linux平台下编译,例如编译驱动就需要在 ...
- Java基础学习总结(46)——JAVA注解快速入门
各位开发童鞋,注解这个东西我们肯定每天都能看见,也许有时候看的太多了到是会忽略注解这东西具体是如何工作的.今天在这里用最短的篇幅快速讲解下注解的原理,对这块记的不太清楚的同学也可以再次看看,下次有人详 ...
- ScrollView反弹效果的实现
发现非常多APP的界面都能够滑动,QQ.微信等等,自己琢磨了下.效果例如以下: 代码:ScrollView package com.wsj.wsjdemo; import android.conten ...
- 面试题:Student s = new Student();在内存中做了哪些事情?即创建一个对象做了哪些事情
lStudent s = new Student();在内存中做了哪些事情? •载入Student.class文件进内存(方法区) •在栈内存为s开辟空间 •在堆内存为学生对象开辟空间 •对学生对象的 ...
- sass09
scss /* 1.使用自定义function和@each实现栅格布局. @function buildLayout($num: 5){ } 结果: col1{width: 20%} col2{wid ...
- 5.array
#include <iostream> #include <array> #include <algorithm> using namespace std; //a ...
- 将ubuntu安装在用剩下的硬盘改装成的移动硬盘时遇到的问题及解决办法
安装时分完盘后提示:“分配到/的分区开始于3584字节,使用磁盘的最小对齐,这可能造成非常差的性能..." 解决办法: 回到windows使用分区助手等工具先分好盘而不是在安装时分盘(这样分 ...
- 使用物化视图解决GoldenGate不能使用中文表名问题
源端: conn sh/sh create table "学生" ("学号" number primary key,"姓名" varchar ...