(校赛) URAL 1993 This cheeseburger you don't need

Master Yoda is the oldest member of the Jedi Council. He conducts preparatory classes of little Younglings up to the moment they get a mentor. All Younglings adore master Yoda and they hope to grow
as strong and wise as he is. Just like all little children, Younglings are absolutely hooked on new games and ideas. Now they decided to learn to speak just like master Yoda. Help the Younglings understand how Yoda would say this or that sentence.

Yoda is speaking the Galactic language using the specific word order — so-called "object-subject-verb".

Your program receives a sentence that interests the Younglings. They have already highlighted all important parts in the sentence. They use the curly {}-brackets for objects, round ()-brackets for subjects
and square []-brackets for verbs.

A sentence in the input can be simple or complex. If the sentence is complex, then it consists of two simple sentences separated by a comma. Sometimes a comma is followed by a conjunction that is not
in the brackets.

Each simple question has exactly one object, one subject and one verb. Your task is to simply put them in the correct order. Namely, first the object, then the subject, finally the verb. Also, please
do not forget that only the first word in the whole sentence should begin with capital letter.

Input

The single line contains a sentence that interests the Younglings. The length of the sentence does not exceed 100 characters. All the words in the sentence consist of Latin letters. The first letter
of the first word is capitalized and the rest are small. The sentence may contain a comma. Each simple sentence contains all three types of brackets. Each pair of brackets surrounds one or more words. No pair of brackets can surround the other bracket. Brackets
are always located on the borders of words. The words in the sentence are separated by a single space. There is no space character before a comma or a closing bracket and also after an opening bracket. The conjunction (which can be only after a comma) is the
only word that is not surrounded by a pair of brackets.

Output

Print the sentence with the word order Yoda would use. All brackets must be omitted. You should separate the words by a single space.

Samples

input
(We) [are] {blind}, if (we) [could not see] {creation of this clone army}
output
Blind we are, if creation of this clone army we could not see
input
{Truly wonderful} (the mind of a child) [is]
output
Truly wonderful the mind of a child is

Problem Author: Denis Dublennykh (prepared by Eugene Kurpilyansky)

按题中我标志的顺序输出=。=

恶心的模拟。。。。。。。。

怎么模拟的详见我的挫码。

因为就三种循序,我开了了个二维数组保存,

到三个的时候就输出,其他的原样输出。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<limits.h>
using namespace std;
char s[1100];
char a[3][110];
int main()
{
    while(gets(s))
    {
        int len=strlen(s);
        int t=0;
        int r=0;
        for(int i=0;i<len;i++)
        {
            if(s[i]=='(')
            {
                int l=0;
                for(i++;;i++)
                {
                    if(s[i]==')')
                        break;
                    a[1][l++]=(s[i]>='A'&&s[i]<='Z'?s[i]-'A'+'a':s[i]);
                }
                t++;
                if(t!=3)//吞空格
                    i++;
            }
            else if(s[i]=='{')
            {
                int l=0;
                for(i++;;i++)
                {
                    if(s[i]=='}')
                        break;
                    a[0][l++]=(s[i]>='A'&&s[i]<='Z'?s[i]-'A'+'a':s[i]);
                }
                t++;
                if(t!=3)//吞空格
                    i++;
            }
            else if(s[i]=='[')
            {
                int l=0;
                for(i++;;i++)
                {
                    if(s[i]==']')
                        break;
                    a[2][l++]=(s[i]>='A'&&s[i]<='Z'?s[i]-'A'+'a':s[i]);
                }
                t++;
                if(t!=3)//吞空格
                    i++;
            }
            else
                printf("%c",s[i]);
            if(t==3)
            {
                if(r==0&&a[0][0]>='a'&&a[0][0]<='z')//首字母大写
                   a[0][0]=a[0][0]-'a'+'A';
                r=1;
                printf("%s %s %s",a[0],a[1],a[2]);
                memset(a,0,sizeof(a));
                t=0;
            }
        }
        printf("\n");
    }
    return 0;
}

(校赛) URAL 1993 This cheeseburger you don't need

时间: 2024-10-09 09:09:17

(校赛) URAL 1993 This cheeseburger you don't need的相关文章

(校赛)URAL 1998 The old Padawan

Luke Skywalker is having exhausting practice at a God-forsaken planet Dagoba. One of his main difficulties is navigating cumbersome objects using the Power. Luke's task is to hold several stones in the air simultaneously. It takes complete concentrat

(校赛)URAL 1991 The battle near the swamp

In the battle with the Trade Federation, Queen Amidala decided to ask gungans for help. Jar Jar Binks escorted the Queen and her people to the holy place where they had an agreement. The gungans agreed to provide their army in order to get the droids

CSU 1425 NUDT校赛 I题 Prime Summation

这个题本来有希望在比赛里面出了的 当时也想着用递推 因为后面的数明显是由前面的推过来的 但是在计算的时候 因为判重的问题 ...很无语.我打算用一个tot[i]来存i的总种树,tot[i]+=tot[j]//j为可以由j推到i的一系列数,但这样是不对的,会产生大量重复计算... 看了下标程才发现要用二维来计算出种类总数,f[i][j]+=sum(f[i-j][k]) 表示在推i数的时候,第一个素数为j的种类数,注意j一定为素数,而且k不能大于j...标程里面处理的比较简练,就学了下他的写法. 至

校赛总结

写写校赛总结....... 这两次校赛是我们组队以后第一次的比赛...第一场打得很拙,第二场还可以吧,第一场校赛--毕竟是期待了很久的校赛,所以感觉还是很紧张,吃饭的时候打了二两,剩了一大半==, 这次我们队名叫 I_Love_High_Math......没走到现场,就快下雨了,真的有点郁闷==.到了以后下雨了,和一个队友被困雨中,,出来以后衣服湿了,一开始就悲剧了...     然后一开场就感觉不好.比赛开始的时候,我去写头文件,然后W说A是水题,然后叫我写,平时都是我写第一题的这次我不想开

NYOJ-682 小媛在努力 (郑大第六届校赛 模拟)

链接:click here 题意: 描述 在多媒体数据处理中,数据压缩算法尤为重要.小媛上完课后就想自己发明一个数据压缩算法.她想呀想,终于想到一个方法.在多媒体数据中有很多数据都是重复的,所以她想把连续相同的数据用数据出现的次数和数据本身表示.例如:1 1 1 2 3 3 3 3 3  压缩后及为3 1 1 2 5 3(表示3个1,1个2和5个3).有想法后小媛就希望把它用代码实现了.但是大家都知道小媛现在整天都忙着苦B的复习考研,连电脑都摸不到.所以她希望作为ACMer的你帮她写一下. 输入

HDU多校赛第9场 HDU 4965Fast Matrix Calculation【矩阵运算+数学小知识】

难度上,,,确实,,,不算难 问题是有个矩阵运算的优化 题目是说给个N*K的矩阵A给个K*N的矩阵B(1<=N<=1000 && 1=<K<=6),先把他们乘起来乘为C矩阵,然后算C^(N*N) 相当于 ABABABABABABAB...=(AB)^(N*N) 不如 A(BA)^(N*N-1)B 因为BA乘得K*K的矩阵,K是比较小的 #include <cstdio> #include <cstdlib> #include <cstr

ZJU校赛 一道计数题

题意是这样的 给定一个n*m的整数矩阵 n和m均小于1000 对这个矩阵删去任意行和列后剩余一个矩阵为M{x1,x2,,,,xm;y1,y2,,,,,yn}表示删除任意的M行N列 对于这个剩下的矩阵,我们考虑其中是否存在特殊的元素,保证这些元素是所在行最大,所在列最小的元素 且非之一. 求对于所有删法,上述元素个数之和 对10^9+7取余. 显然所有删法 有2^(n+m)种 暴力是搞不定的. 于是反过来看,矩阵的元素最多有10^6个 是不是可以考虑每一个元素对最终答案的贡献? 所谓贡献,就是它在

山科第三届校赛总结

这次山科的校赛算是省赛前的一次正式的检验吧,暴露了我们队伍之前训练很多没发现的问题. 比赛的过程真的算是有惊无险,差点就GG... 我们入场晚了一会,我刚读完C题,就发现已经有人过了F题了,我去看F题,是个统计闰年的水题,很快就敲过了.回去想接着看C,感觉也很水,这时cerberux说这个用个map就A了,我让他来敲,可是他好像用的不是很熟练,这道题敲的很慢,交上去还wa了...我回过头仔细看这题,觉得扫一遍统计一次最多连续出现的次数就可以了,这才把这个水题过了.然后我去敲G,G题我出现了很严重

BZOJ 3093: [Fdu校赛2012] A Famous Game

3093: [Fdu校赛2012] A Famous Game Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 242  Solved: 129[Submit][Status][Discuss] Description Mr. B and Mr. M like to play with balls. They have many balls colored in blue and red. Firstly, Mr. B randomly picks