• 【ECJTU_ACM 11级队员2012年暑假训练赛(8) J Word Problem】


    B题要套一个数论的模版,注意m=1!! C题可以二分匹配,把行列看作点; 不能开百度,开谷歌搜题解,再次强调!一经发现,取消成绩!

    ECJTU_ACM 11级队员2012年暑假训练赛(8)
    4:30:00
     
     
              
    J - Word Problem
    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    Description

    给出一个完整的句子,这个句子中不包含不可见字符或者空格,于是在这个句子中有许多不同的单词。一个单词是指一串连续的最长的英文字母(大写或小写)。例如"#abc#"中,"abc"就是一个单词,而"ab","bc"都不算单词。

    Input

    输入包含多组数据 输入数据第一行是一个句子,只包含可见字符(不包含空格)。句子长度不超过 100。

    Output

    按单词出现的顺序输出不同的单词。如果一个单词出现多次则只有第一次出现时输出。

    Sample Input

    Orz_YaYaMao_Orz_Daxia_Orz_EveryOne
    

    Sample Output

    Orz
    YaYaMao
    Daxia
    EveryOne 
    

    FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
    All Copyright Reserved ©2010-2012 HUST ACM/ICPC TEAM 
    Anything about the OJ, please ask in the forum, or contact author:Isun
    Server Time: 2012-08-13 10:55:21
     
     
      1 // Project name : J ( Word Problem ) 
      2 // File name    : main.cpp
      3 // Author       : iCoding
      4 // E-mail       : honi.linux@gmail.com
      5 // Date & Time  : Fri Aug 10 12:32:18 2012
      6 
      7 
      8 #include <iostream>
      9 #include <stdio.h>
     10 #include <string>
     11 #include <cmath>
     12 #include <algorithm>
     13 using namespace std;
     14 
     15 /*************************************************************************************/
     16 /* data */
     17 
     18 #ifndef MAXN
     19 #define MAXN 100
     20 #endif
     21 
     22 string iList[MAXN];
     23 int iTop;
     24 
     25 string s;
     26 int sTop;
     27 
     28 char s_tmp[MAXN];
     29 int s_tmp_top;
     30 /*************************************************************************************/
     31 /* procedure */
     32 
     33 void iShowList()
     34 {
     35     for (int i = 0; i <= iTop; i++)
     36     {
     37         cout << iList[i] << endl;
     38     }
     39 }
     40 
     41 void iInit()
     42 {
     43     iTop = -1;
     44 
     45     sTop = s.length() - 1;
     46     if ((s[sTop] >= 'a' && s[sTop] <= 'z') || (s[sTop] >= 'A' && s[sTop] <= 'Z'))
     47     {
     48         sTop++;
     49         s[sTop] = '_';
     50     }
     51 }
     52 
     53 void iInitTmp()
     54 {
     55     for (int i = 0; i < MAXN; i++)
     56     {
     57         s_tmp[i] = '\0';
     58     }
     59     s_tmp_top = -1;
     60 }
     61 
     62 void iCal()
     63 {
     64     iInitTmp();
     65     bool hasword = false;
     66 
     67     for (int i = 0; i <= sTop; i++)
     68     {
     69         if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
     70         {
     71             s_tmp_top++;
     72             s_tmp[s_tmp_top] = s[i];
     73             hasword = true;
     74             //cout << s[i] << endl;
     75         }
     76         else
     77         {
     78             if (hasword)
     79             {
     80                 // go search
     81                 string sss = s_tmp;
     82                 bool iFound = false;
     83                 for (int i = 0; !iFound && i <= iTop; i++)
     84                 {
     85                     if (iList[i] == sss)
     86                     {
     87                         iFound = true;
     88                     }
     89                 }
     90                 if (!iFound)
     91                 {
     92                     iTop++;
     93                     iList[iTop] = sss;
     94                 }
     95                 iInitTmp();
     96                 hasword = false;
     97             }
     98             
     99         }
    100     }
    101 }
    102 
    103 /*************************************************************************************/
    104 /* main */
    105 int main()
    106 {
    107     while (cin >> s)
    108     {
    109         iInit();
    110         iCal();
    111         iShowList();
    112     }
    113     return 0;
    114 }
    115 
    116 // end 
    117 // Code by Sublime text 2
    118 // iCoding@CodeLab 
  • 相关阅读:
    关于勉励
    jQuery MiniUI
    DES 加密解密
    软件设计的原则
    关于jFinal
    医疗保险,公积金、养老、生育、工伤、失业保险
    GET和POST的区别(详解)
    单例模式
    ajax 同步和异步的区别
    tomcat部署web项目的3中方法
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2635992.html
Copyright © 2020-2023  润新知