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 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
随机推荐
- 最好最实用的PHP二次开发教程
◆二次开发 1.什么是二次开发? 二次开发,简单的说就是在现有的软件上进行定制修改,功能的扩展,然后达到自己想要的功能和效果,一般来说都不会改变原有系统的内核. 2.为什么要二次开发? 随着信息化技术 ...
- HDU 5489 Removed Interval
题意:求一段序列中删掉L个连续元素后的LIS. 解法:我的想法很复杂= =怎么说呢……首先用nlogn的方法求LIS得到的序列dp的第i项的意义为上升子序列所有长度为i的序列结尾元素的最小值,那么先倒 ...
- LXD 2.0 系列(二):安装与配置
导读 简单来说,LXD是一个守护进程,为LXC容器的管理提供一组REST API.主要目标是提供一种类虚拟机的用户体验,是一种第三方的容器管理工具.下面呢,我们来介绍LXD 2.0 的安装与配置 安装 ...
- C# winform 若要在加载设计器前避免可能发生的数据丢失,必须纠正以下错误
winform中有时添加了新控件之后编译会报错: 若要在加载设计器前避免可能发生的数据丢失,必须纠正以下错误,如图: 解决方案: 1.“解决方案”→“批生成”→“清理”→“确定”: 2.“解决方案”→ ...
- Hie with the Pie(POJ 3311状压dp)
题意:披萨店给n个地方送披萨,已知各地方(包括披萨店)之间花费的时间,求送完所有地方并回到店花费的最小时间 分析:状态好确定dp[i][j],i中1表示地方已送过,否则为0,j为当前状态最后一个送过的 ...
- linux常用命令之--文件打包与压缩命令
linux的文件打包与压缩命令 1.压缩与解压命令 compress:用于压缩指定的文件,后缀为.z 其命令格式如下: compress [-d] 文件名 常用参数: -d:解压被压缩的文件(.z为后 ...
- pci 记录
用linux 下的sysfs可以方便的查看pci设备的配置和资源. 所有的pci设备在/sys/bus/pci/device 下面看到 pci配置空间对应的是设备对应的目录下的config文件,是二进 ...
- lighttpd+fastcgi模块分析
一开始不怎么明白fastcgi和cgi的区别,查了资料说,fastcgi多了一个进程池,不要每次都fork和退出 这个不是重点,还是对着代码看吧 怎样在lighttpd运行php呢,需要下面这样配置 ...
- MAC机常用快捷键整理表格
MAC机常用快捷键整理表格 范围 快捷键 说明 图形 (Command 键)在某些 Apple 键盘上,此键也可能为标志() Control (Control 键) Alt Opt ...
- Juicer javascript 模板引擎
模板引擎是为了使用户界面与业务数据(内容)分离而产生的,它可以生成特定格式的文档,用于网站的模板引擎就会生成一个标准的HTML文档. js模板引擎包括如下:template官方参考:http://au ...