Saturday, June 6, 2015

LightOJ - 1113 - Discover the Web

  1. #include <bits/stdc++.h>
  2. #define S 103
  3. using namespace std;
  4.  
  5. string Browser[S];
  6.  
  7. int main(){
  8.     int t, last, ind, cs = 0;
  9.     string inp;
  10.     cin >> t;
  11.     while(t--){
  12.         last = 0, ind = 0;
  13.         Browser[last] = "http://www.lightoj.com/";
  14.         cout << "Case " << ++cs << ":" << endl;
  15.         while(cin >> inp){
  16.             if(inp == "QUIT")break;
  17.             else if(inp == "VISIT"){
  18.                 cin >> inp;
  19.                 cout << inp << endl;
  20.                 Browser[++ind] = inp;
  21.                 last = ind;
  22.             }
  23.             else if(inp == "FORWARD"){
  24.                 if(ind+1 > last)puts("Ignored");
  25.                 else cout << Browser[++ind] << endl;
  26.             }
  27.             else if(inp == "BACK"){
  28.                 if(ind-1 < 0)puts("Ignored");
  29.                 else cout << Browser[--ind] << endl;
  30.             }
  31.         }
  32.     }
  33.     return 0;
  34. }

No comments:

Post a Comment