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对区间分裂合并翻转,模板题. ...
随机推荐
- 机器学习(4)之Logistic回归
机器学习(4)之Logistic回归 1. 算法推导 与之前学过的梯度下降等不同,Logistic回归是一类分类问题,而前者是回归问题.回归问题中,尝试预测的变量y是连续的变量,而在分类问题中,y是一 ...
- firefox插件poster的使用,发起自定义http请求
快捷键:ctrl+alt+p 在开发WEB程序的时候,经常需要模拟http请求,接收服务器响应,从而检验程序的正确性. Firefox插件poster,可以模拟各种http请求,并详细设置请求参数,比 ...
- C#编译时出现“不安全代码只会在使用 /unsafe 编译的情况下出现”错误的解决
原因是:在编译的代码里面有不安全类型unsafe方法或类!解决方法:将项目属性页中生成下的“允许不安全代码”复选框打上对勾即可,方法如下:项目属性对话框->生成->允许不安全代码块 选中即 ...
- Windows 不能在 本地计算机 启动 SQL Server 服务 错误代码126
本文转自:http://www.cnblogs.com/yuerdongni/archive/2012/08/18/2645140.html 在使用SQL2005(或2008)是可能会遇到错误提示: ...
- 关于Android API的理解
举个例子: 比如程序中用到了android.content.ClipboardManager这个类, 而该类是在API 11才添加到 “库”. (原谅我,不理解Google API 文档里的 adde ...
- label标签的属性
//label标签的属性 - (void)viewDidLoad { //初始化一个label1标签对象,初始化有很多方法,最原始的就是init,此处用带有frame的方法 UILabel *labe ...
- 一种用单片机AD采样方式来检测交流市电电压的方法
下面介绍一种用单片机AD采样的方式检测市电电压的方法 要检测交流市电的电压,通常有两种方法 一.通过频繁的采样后再求平均值来获得实际电压值 二.通过采样交流市电的峰值,再通过算法得出实际电压值 这里 ...
- BootStrap--Tables(表格) MVC中不刷新做增,删,改(C#)
自带的Tables会有自动分页,搜索等一些动能,很方便,唯一的不足就是添加,修改,删除数据需要刷新页面,并不能静态. 下面说的是如何不刷新页面(Ajax)去执行增,删,改操作. 需要用到的样式,JS库 ...
- Android常用的物理按键及其触发事件
Activity和View都能接收触摸和按键,如果响应事件只需要在继承类里复写事件函数即可:当一个视图(如一个按钮)被触摸时,该对象上的 onTouchEvent() 方法会被调用.不过,为了侦听这个 ...
- "ping: unknown host www.baidu.com" 解决方法
如果某台Linux服务器ping不通域名, 如下提示: # ping www.baidu.comping: unknown host www.baidu.com 如果确定网络没问题的情况下, 可以通过 ...