Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words
Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words
https://code.google.com/codejam/contest/351101/dashboard#s=p1
Problem
Given a list of space separated words, reverse the order of the words. Each line of text contains L letters and W words. A line will only consist of letters and space characters. There will be exactly one space character between each pair of consecutive words.
Input
The first line of input gives the number of cases, N.
N test cases follow. For each test case there will a line of letters and space characters indicating a list of space separated words. Spaces will not appear at the start or end of a line.
Output
For each test case, output one line containing "Case #x: " followed by the list of words in reverse order.
Limits
Small dataset
N = 5
1 ≤ L ≤ 25
Large dataset
N = 100
1 ≤ L ≤ 1000
Sample
| Input | Output |
3 |
Case #1: test a is this |
Solution:
vector<string> solve1(vector<string>words)
{
reverse(words.begin(), words.end());
return words;
} int main() {
freopen("in", "r", stdin);
//freopen("out", "w", stdout); int t_case_num;
scanf("%d\n", &t_case_num);
if (!t_case_num) {
cerr << "Check input!" << endl;
exit();
} // Read input set
for (int case_n = ; case_n <= t_case_num; case_n++) { string line;
getline(cin, line);
stringstream ss(line); vector<string>words; string w;
while (ss >> w) {
words.push_back(w);
} auto result = solve1(words);
printf("Case #%d: ", case_n);
for (int i = ; i < result.size(); i++) {
cout << result.at(i) << " ";
}
printf("\n"); } fclose(stdin);
fclose(stdout);
return ;
}
Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words的更多相关文章
- Google Code Jam Africa 2010 Qualification Round Problem A. Store Credit
Google Code Jam Qualification Round Africa 2010 Problem A. Store Credit https://code.google.com/code ...
- Google APAC----Africa 2010, Qualification Round(Problem B. Reverse Words)----Perl 解法
原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p1 问题描述: Problem Given a list of s ...
- Google APAC----Africa 2010, Qualification Round(Problem C. T9 Spelling)----Perl 解法
原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p2 问题描述: Problem The Latin alphabe ...
- Google APAC----Africa 2010, Qualification Round(Problem A. Store Credit)----Perl 解法
原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p0 问题描述: Problem You receive a cre ...
- Google Code Jam 第一题
通过的第一题,留做纪念,呵呵,非常简单,Africa 2010, Qualification Round: Store Credit. #include <stdio.h> #includ ...
- [C++]Store Credit——Google Code Jam Qualification Round Africa 2010
Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local ...
- Google Code Jam 2010 Round 1C Problem A. Rope Intranet
Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...
- [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha
Problem B. Cookie Clicker Alpha Introduction Cookie Clicker is a Javascript game by Orteil, where ...
- [Google Code Jam (Qualification Round 2014) ] A. Magic Trick
Problem A. Magic Trick Small input6 points You have solved this input set. Note: To advance to the ...
随机推荐
- python中赋值、浅拷贝、深拷贝详解(转)
一.赋值 >>> a = [1, 2, 3]>>> b = a>>> print(id(a), id(b), sep='\n')139701469 ...
- 发行NEO的NEP-5合约代币
NEO常见的资产有三种 TOKEN (全局资产) Share (全局资产,股份 ) NEP-5 (合约代币,相当于ETH的ERC20) NEP-5 合约代码 https://github.com/AN ...
- Android中的通信Volley
1. Volley简介 我们平时在开发Android应用的时候不可避免地都需要用到网络技术,而多数情况下应用程序都会使用HTTP协议来发送和接收网络数据.Android系统中主要提供了两种方式来进行H ...
- 63.UniquePaths II---dp
题目链接 题目大意:与62题类似,只是这个题中间有障碍. 法一:dfs,依旧超时.代码如下: public int uniquePathsWithObstacles(int[][] obstacleG ...
- .NET连接Oracle的方法
.NET连接Oracle的方法 方式1:直接利用.NET的oracle驱动连接 引用System.data.oracleclient; using System.data.oracleclient; ...
- Tutorial 6: ViewSets & Routers
转载自:http://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/ Tutorial 6: ViewSets & ...
- 基于TCP协议的聊天室控制台版
我之前写过一篇博客,主要是基于TCP协议实现的聊天室swing版,在此再写一个基于TCP协议实现的聊天室控制台版,便于学习和比较. package 聊天室console版.utils; import ...
- 7. Docker Compose 项目
- hdu 1597(矩阵快速幂)
1597: 薛XX后代的IQ Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 228 Solved: 55[Submit][Status][Web Bo ...
- 【LOJ】 #2013. 「SCOI2016」幸运数字
题解 最大异或和,明显是个线性基 然而还有那么多路径--那就树分治,反正点数看起来很少,就是为了让人乘上一个60的常数嘛 把一个树的点分树记录下来,然后看看询问的两个点彼此相同的最后一个父亲是谁,把这 ...