<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的更多相关文章

  1. UVA 11922 Permutation Transformer(平衡二叉树)

    Description Write a program to transform the permutation 1, 2, 3,..., n according to m instructions. ...

  2. 全排列 UVA 11525 Permutation

    题目传送门 题意:训练指南P248 分析:逆向考虑,比如一个全排列:7345261,它也可以表示成题目中的形式,第一个数字7是由6 * (7 - 1)得到的,第二个数字3有2 * (7 - 2)得到, ...

  3. uva 11922 Permutation Transforme/splay tree

    原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 伸展树的区间翻转剪切... 如下: #include< ...

  4. UVa 11922 - Permutation Transformer 伸展树

    第一棵伸展树,各种调试模板……TVT 对于 1 n 这种查询我处理的不太好,之前序列前后没有添加冗余节点,一直Runtime Error. 后来加上冗余节点之后又出了别的状况,因为多了 0 和 n+1 ...

  5. uva 11922 - Permutation Transformer

    splay的题: 学习白书上和网上的代码敲的: #include <cstdio> #include <cstring> #include <cstdlib> #i ...

  6. UVA 11922 Permutation Transformer(Splay Tree)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 [思路] 伸展树+打标记. 用伸展树维护这个序列,使得能 ...

  7. UVA 11525 Permutation(树状数组)

    题目意思是说  给你一个数k  然后有k个si   问你1--k 的第n个全排列是多少   注意是 1 2 3...k的全排列 不是si的 N=   由观察得知(k-i)!就是k-i个数字的全排列种数 ...

  8. UVA 11525 Permutation (树状数组+YY)

    题意:给你k个数Si,然后给你一个等式   H= ∑  Si ∗ (K − i)!  (i=(1->k)且0 ≤ Si ≤ K − i). 叫你求出第H个全排列 其实这是一个康托展开:X=a[n ...

  9. UVA - 11922 Permutation Transformer (splay)

    题目链接 题意:你的任务是根据m条指令改变排列{!,2,3,...,n}.每条指令(a,b)表示取出第a~b个元素,翻转后添加到排列的尾部.输出最终序列. 解法:splay对区间分裂合并翻转,模板题. ...

随机推荐

  1. Solr4.8.0源码分析(7)之Solr SPI

    Solr4.8.0源码分析(7)之Solr SPI 查看Solr源码时候会发现,每一个package都会由对应的resources. 如下图所示: 一时对这玩意好奇了,看了文档以后才发现,这个serv ...

  2. ubuntu后台运行命令行

    ubuntu 程序后台运行几个方法 . 程序后加上“&” ,即 “./myjob &”, 将命令放入到一个作业队列中,可以用命令“jobs” 查看 . 将1中的命令放在 “()”中, ...

  3. SPSS相关和回归分析

    1.语文和数学成绩都受IQ的影响而且相互影响,则分析语文和数学的关系时需要偏相关分析.2.距离分析用于探索相似性,比如给了某年的12个月三个城市的气温数据,然后分析,会得到一个相似性矩阵,这是个对称阵 ...

  4. Cracking the coding interview--Q2.4

    Write code to partition a linked list around a value x, such that all nodes less than xcome before a ...

  5. pl/sql 程序块里打印问题

    declare v_number NUMBER; v_number2 NUMBER; begin select count(*) into v_number from dual; DBMS_OUTPU ...

  6. Subway POJ 2502

    题目链接: http://poj.org/problem?id=2502 题目大意: 你刚从一个安静的小镇搬到一个吵闹的大城市,所以你不能再骑自行车去上学了,只能乘坐地铁或者步行去上学.因为你不想迟到 ...

  7. jps(JVM Process Status)

    功能   列出正在运行的虚拟机进程,并显示虚拟机执行主类(Main Class,main()函数所在类)的名称,以及这些进程的本地虚拟机的唯一ID(LVMID,Local Virtual Machin ...

  8. HashTable与HashMap使用总结

    1.HashTable和HashMap比较 1)继承的父类不同. Hashtable继承自Dictionary类,而HashMap继承自AbstractMap类.但二者都实现了Map接口. publi ...

  9. Minimum Depth of Binary Tree ——LeetCode

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  10. 深入理解java的异常处理机制

     JAVA异常的概念    异常指不期而至的各种状况,如:文件找不到.网络连接失败.非法参数等.异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程.Java通 过API中Throwable类的 ...