Codeforces Gym 100286I iSharp 水题
Problem I. iSharp
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/I
Description
You are developing a new fashionable language that is not quite unlike C, C++, and Java. Since your language should become an object of art and fashion, you call it i # (spelled i-sharp). This name combines all the modern naming trends and also hints at how smart you are. Your language caters for a wide auditory of programmers and its type system includes arrays (denoted with “[]”), references (denoted with “&”), and pointers (denoted with “*”). Those type constructors can be freely combined in any order, so that a pointer to an array of references of references of integers (denoted with “int&&[]*”) is a valid type. Multiple variables in i # can be declared on a single line with a very convenient syntax where common type of variables is given first, followed by a list of variables, each optionally followed by additional variable-specific type constructors. For example, the following line: int& a*[]&, b, c*; declares variables a, b, and c with types “int&&[]*”, “int&”, and “int&*” correspondingly. Note, that type constructors on the right-hand sides of variables in i # bind to variable and their order is reversed when they are moved to the left-hand side next to type. Thus “int*& a” is equivalent to “int a&*”. However, you discover that coding style with multiple variable declarations per line is confusing and is outlawed in many corporate coding standards. You decide to get rid of it and refactor all existing i # code to a single variable declaration per line and always specify type constructor next to the type it refers to (instead of the right-hand side of variable). Your task it to write such refactoring too
Input
The input file contains a single line with a declaration of multiple variables in i #. The line starts with a type name, followed by zero, one, or more type constructors, followed by a space, followed by one or more variable descriptors separated by “,” (comma) and space, and terminated by “;” (semicolon). Each variable descriptor contains variable name, followed by zero, one, or more type constructors. Type name and variable names are distinct and consist of lowercase and uppercase English letters from “a” to “z” or “A” to “Z”. The line contains at most 120 characters and does not contain any extra spaces.
Output
Write to the output file a line for each variable declared in the input file. For each variable write its declaration on a single line in the same format as in the input file, but with all type constructors next to its type. Separate type with all type constructors from a variable name by a single space. Do not write any extra spaces.
Sample Input
int& a*[]&, b, c*;
Sample Output
int&&[]* a;
int& b;
int&* c;
HINT
题意
水
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
string str;
string sb;
string temp;
string name;
string sign;
int a1 = , a2 = , a3 = ; void GetName()
{
name.clear();sign.clear();
for(int i = ; i < temp.size() ; ++ i)
{
if ( (temp[i] <= 'Z' && temp[i] >= 'A' ) || (temp[i] <= 'z' && temp[i] >= 'a') )
{
name.pb(temp[i]);
}
else
sign.pb(temp[i]);
}
reverse(sign.begin(),sign.end());
for(int i = ; i < sign.size() ; ++ i)
{
if (sign[i] == '[') sign[i] = ']';
else if(sign[i] == ']') sign[i] = '[';
}
} int main(int argc,char *argv[])
{
freopen("isharp.in","r",stdin);
freopen("isharp.out","w",stdout);
getline(cin,str);
int bg;
for(int i = ; i< str.size() ; ++ i)
{
if (str[i] == ' ')
{
sb = str.substr(,i);
bg = i;
break;
}
}
int pre = bg;
for(int i = bg ; i < str.size() ; ++ i)
{
if (str[i] == ',' || str[i] == ';')
{
temp.clear();
temp = str.substr(pre+,i-pre-);
GetName();
cout << sb << sign << " "<< name << ';'<<endl;
i ++;
pre = i;
}
}
return ;
}
题,然后倒着输出字符就好了
题解:
模拟一下就好了
代码:
Codeforces Gym 100286I iSharp 水题的更多相关文章
- Codeforces Gym 100286I iSharp 模拟
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- CodeForces Gym 100685C Cinderella (水题)
题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- UVaLive 6591 && Gym 100299L Bus (水题)
题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
随机推荐
- 配置ORACLE 客户端连接到数据库
--================================= -- 配置ORACLE 客户端连接到数据库 --================================= Oracle ...
- 从网页监听Android设备的返回键
最近搞Android项目的时候,遇到一个比较蛋疼的需求,需要从Client App调用系统浏览器打开一个页面,进行杂七杂八的一些交互之后,返回到App.如何打开浏览器和如何返回App这里就不说了,有兴 ...
- android学习—— context 和 getApplicationContext()
一直看到好多应用里面,随手使用getApplicationContext(),不想说也不乐意说,今天转载一篇文章区分两者的区别: 在android中常常会遇到与context有关的内容 浅论一下con ...
- H264相关知识
1.基本概念 I frame :帧内编码帧 又称intra picture,I 帧通常是每个 GOP(MPEG 所使用的一种视频压缩技术)的第一个帧,经过适度地压缩,做为随机访问的参考点,可以当成图象 ...
- hdu 3172 Virtual Friends(并查集)University of Waterloo Local Contest 2008.09
题目比较简单,但作为长久不写题之后的热身题还是不错的. 统计每组朋友的朋友圈的大小. 如果a和b是朋友,这个朋友圈的大小为2,如果b和c也是朋友,那么a和c也是朋友,此时这个朋友圈的大小为3. 输入t ...
- [Everyday Mathematics]20150110
试证: $$\bex \vlm{n}\frac{\ln^2n}{n}\sum_{k=2}^{n-2}\frac{1}{\ln k\cdot \ln(n-k)}=1. \eex$$
- MultiSet
Guava引进了JDK里没有的,但是非常有用的一些新的集合类型.所有这些新集合类型都能和JDK里的集合平滑集成.Guava集合非常精准地实现了JDK定义的接口.Guava中定义的新集合有: Multi ...
- 用Vmware安装centos5
Vmware安装过程就不详述了,这里从创建虚拟机开始记录. 选择创建虚拟机 下一步 选择稍后安装 选择安装的操作系统版本,需要说明的是,CentOs 5 就是RHEL 5 设置虚拟机名称及虚拟机位置 ...
- bzoj 2132 圈地计划(黑白染色,最小割)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2132 [题意] 给定n*m个区域,建工业区价值A,建商业区价值B,如果(i,j)有k个 ...
- 最短路+线段交 POJ 1556 好题
// 最短路+线段交 POJ 1556 好题 // 题意:从(0,5)到(10,5)的最短距离,中间有n堵墙,每堵上有两扇门可以通过 // 思路:先存图.直接n^2来暴力,不好写.分成三部分,起点 终 ...