uva 482 - Permutation Arrays
<int, double> --> <int, string> 从而避免了输出格式;
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std; int main()
{
int t, count = ;
string line1, line2;
int index;
string value;
vector<pair<int, string>> store;
cin >> t;
getchar();
while(t--)
{
getchar();
count ++;
getline(cin, line1);
getline(cin, line2);
stringstream ss1(line1), ss2(line2);
while(ss1 >> index)
{
ss2 >> value;
store.push_back(pair<int, string>(index, value));
}
sort(store.begin(), store.end());
if(count > ) cout << endl;
for(int i = ; i < store.size(); i++)
cout << store[i].second << endl; store.clear();
} return ;
}
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
using namespace std; int main()
{
int T;
cin >> T;
while(T--)
{
string str, s;
stringstream ss;
vector<int> ind;
map<int, string> Map; getline(cin, str); // T 后面的\n
getline(cin, str); // 空行 getline(cin, str); // index
ss << str;
while(ss >> s) ind.push_back(stoi(s)); for(int i= ;i < ind.size(); i++)
cin >> str, Map[ind[i]] = str; for(int i = ; i < ind.size(); i++)
cout << Map[i+] << endl;
if(T > )
cout << endl;
}
return ;
} string toString(int I)
{
stringstream ss;
string str;
ss << I;
ss >> str; return str;
}
// 输入输出是怎么回事???
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map> using namespace std; #define FOI(i, A, B) for(i = A; i <= B; i++)
#define FOD(i, A, B) for(i = A; i >= b; i--) string toString(int I)
{
stringstream ss;
string str;
ss << I;
ss >> str; return str;
} int main()
{
int T;
cin >> T;
string str, s;
while(T--)
{
getline(cin, str);
getline(cin, str);
vector<string> ind, val;
map<string, string> Map;
stringstream ss;
getline(cin, str);
ss << str;
while(ss >> s) ind.push_back(s);
int N = ind.size(), i;
FOI(i, , N-)
{
cin >> str;
Map[ind[i]] = str;
}
FOI(i, , N-)
cout << Map[toString(i+)] << endl;
if(T > )
cout << endl;
}
return ;
}
uva 482 - Permutation Arrays的更多相关文章
- UVA 11922 Permutation Transformer(平衡二叉树)
Description Write a program to transform the permutation 1, 2, 3,..., n according to m instructions. ...
- 全排列 UVA 11525 Permutation
题目传送门 题意:训练指南P248 分析:逆向考虑,比如一个全排列:7345261,它也可以表示成题目中的形式,第一个数字7是由6 * (7 - 1)得到的,第二个数字3有2 * (7 - 2)得到, ...
- uva 11922 Permutation Transforme/splay tree
原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 伸展树的区间翻转剪切... 如下: #include< ...
- UVa 11922 - Permutation Transformer 伸展树
第一棵伸展树,各种调试模板……TVT 对于 1 n 这种查询我处理的不太好,之前序列前后没有添加冗余节点,一直Runtime Error. 后来加上冗余节点之后又出了别的状况,因为多了 0 和 n+1 ...
- uva 11922 - Permutation Transformer
splay的题: 学习白书上和网上的代码敲的: #include <cstdio> #include <cstring> #include <cstdlib> #i ...
- UVA 11922 Permutation Transformer(Splay Tree)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 [思路] 伸展树+打标记. 用伸展树维护这个序列,使得能 ...
- UVA 11525 Permutation(树状数组)
题目意思是说 给你一个数k 然后有k个si 问你1--k 的第n个全排列是多少 注意是 1 2 3...k的全排列 不是si的 N= 由观察得知(k-i)!就是k-i个数字的全排列种数 ...
- UVA 11525 Permutation (树状数组+YY)
题意:给你k个数Si,然后给你一个等式 H= ∑ Si ∗ (K − i)! (i=(1->k)且0 ≤ Si ≤ K − i). 叫你求出第H个全排列 其实这是一个康托展开:X=a[n ...
- UVA - 11922 Permutation Transformer (splay)
题目链接 题意:你的任务是根据m条指令改变排列{!,2,3,...,n}.每条指令(a,b)表示取出第a~b个元素,翻转后添加到排列的尾部.输出最终序列. 解法:splay对区间分裂合并翻转,模板题. ...
随机推荐
- logstash 通过mysql 慢日志了解(?m)
<pre name="code" class="html"># User@Host: zjzc_app[zjzc_app] @ [10.171.24 ...
- POJ2251 Dungeon Master(bfs)
题目链接. 题目大意: 三维迷宫,搜索从s到e的最小步骤数. 分析: #include <iostream> #include <cstdio> #include <cs ...
- POJ3083 Children of the Candy Corn(搜索)
题目链接. 题意: 先沿着左边的墙从 S 一直走,求到达 E 的步数. 再沿着右边的墙从 S 一直走,求到达 E 的步数. 最后求最短路. 分析: 最短路好办,关键是沿着墙走不太好想. 但只要弄懂如何 ...
- BZOJ 1032 [JSOI2007]祖码Zuma
1032: [JSOI2007]祖码Zuma Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 637 Solved: 318[Submit][Stat ...
- -_-#【Backbone】Router
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- T-SQL中return 返回语句学习
return命令用于结束当前程序的执行,返回到上一个调用它的程序或其他程序,其语法格式如下: return 整数值或变量 return语句要指定返回值,如果没有指定返回值,SQL Server系统 ...
- Java学习日记-2.5 关于0和无穷
1. 无穷 Java中将无穷定义为浮点数,分为正负无穷,分别为POSITIVE_INFINITY和NEGATIVE_INFINITY 2. null null在java中可以理解为一个特殊的引用类型, ...
- AngularJS - 基本功能介绍
转载自:http://www.cnblogs.com/powertoolsteam/p/angularjs-introdection.html (写得很好的Angular入门,可以试试) Angula ...
- Runtime.exec()
关于RunTime类的介绍: /** * Every Java application has a single instance of class * <code>Runtime< ...
- ASP.NET页面同时发起多个ajax请求,出现阻塞情况
解决办法:假如页面对Session只读不写,可以在页面的开头加上EnableSessionState="ReadOnly".