Skip to main content
  1. Posts/

POJ 1028 Web Navigation

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

http://poj.org/problem?id=1028

 1
 2
 3
 4    /* ***********************************************
 5    Author :111qqz
 6    Created Time :2016年02月19日 星期五 15时45分01秒
 7    File Name :1028.cpp
 8    ************************************************ */
 9
10    #include <algorithm>
11    #include <cstdio>
12    #include <iostream>
13    #include <cstring>
14    #include <string>
15    #include <cmath>
16    #include <map>
17    #include <stack>
18    #include <queue>
19
20    using namespace std;
21    typedef long long LL;
22    const int inf = 8E8;
23    stack<string> backstack;
24    stack<string> forwardstack;
25    string cur;
26    string cmd;
27    int main()
28    {
29        cur ="http://www.acm.org/";
30
31        while (cin>>cmd)
32        {
33            if (cmd=="QUIT")
34            {
35                break;
36            }
37            if (cmd=="BACK")
38            {
39                if (backstack.empty())
40                {
41                    cout<<"Ignored"<<endl;
42                    continue;
43                }
44                forwardstack.push(cur);
45                cur=backstack.top();
46                backstack.pop();
47                cout<<cur<<endl;
48            }
49            if (cmd=="FORWARD")
50            {
51                if (forwardstack.empty())
52                {
53                    cout<<"Ignored"<<endl;
54                    continue;
55                }
56                backstack.push(cur);
57                cur=forwardstack.top();
58                forwardstack.pop();
59                cout<<cur<<endl;
60            }
61            if (cmd=="VISIT")
62            {
63                backstack.push(cur);
64
65                cin>>cur;
66                while (!forwardstack.empty())  forwardstack.pop();
67                cout<<cur<<endl;
68
69            }
70        }
71
72
73    	return 0;
74    }

Related

poj 1833 排列

·1 min
http://poj.org/problem?id=1833 还是next_permutation. 这次是Int类型的 需要注意的是next_permutation是先判断时候有后继,返回一个bool值,如果为true,就转化到后继。

poj 1256 Anagram

·1 min
http://poj.org/problem?id=1256 题意是说求出一个字符串的全排列,按字典序 需要注意的是字典序和传统意义上的字典序不同

codeforces 548B Mike and Fun

·1 min
http://codeforces.com/problemset/problem/548/B 比赛的时候不懂为什么就没做出来…. 其实很容易想到一个o(q*(n+m))的做法… 就是每次更新,要同时更新当前更新行的最大连续和….O(m)可以完成…然后在O(n)扫一遍,找到所有行中的最大值。 然后需要注意的是,在第一次更改之前就要把每个行的最大值处理出来l.. 然后cf机器真是够快,O(nmq)的1.2S过。。。。