UVA 11991 vector】的更多相关文章

Though Rujia Liu usually sets hard problems for contests (for example, regional contests likeXi’an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu’s Presents 1and 2), he occasionally sets easy problem (for example, ‘the Coco-Cola…
option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142" target="_blank" style="">题目链接:uva 11991 - Easy Problem from Rujia Liu? 题目大意:给出一个包括n个整数的数组,你须要回答若干询问,每次询问两个整数k和v,输出从左到右第k个v的下标 解题思路:用map映射一个vector,相应即为m…
CJOJ 2485 UVa 11991 生日礼物 / UVa 11991 Easy Problem from Rujia Liu? Description (原题来自刘汝佳<训练指南>Page187,UVa 11991.) 可爱的小F就要过生日啦,为了刷存在感,我们的小F十分诚恳(xian de mei shi)地向女神小E要生日礼物.不过傲娇(2333)的小E当然不会随便答应的啦~为了为难小F,小E就说: "如果你能做出这道简单题,我就给你礼物:如果做不出来,嘿嘿嘿嘿-"…
Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he occasionally sets easy probl…
Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he occasionally sets easy probl…
水题 学习一下数据的存储方法. #include<iostream> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> #include<vector> #include<map> using namespace std; int n,m; map<int,vector<int> >a; int main() { w…
11991 - Easy Problem from Rujia Liu? Time limit: 1.000 seconds Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ con…
题目链接: option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142">https://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142 题意: 给一个长度n的序列.有m询问,每一个询问会问第k个出现的数字的下标是多少 用map记录 代码:…
题目传送门 题意:训练指南P187 分析:用vector存id下标,可以用map,也可以离散化用数组存(发现不用离散化也可以) map #include <bits/stdc++.h> using namespace std; map<int, vector<int> >mp; int main(void) { int n, m; while (scanf ("%d%d", &n, &m) == 2) { mp.clear (); f…
STL 使用,,由于数据范围没有 超越极限数据  依旧可以用 vector 搞定: #include<iostream> #include<stdio.h> #include<cstring> #include<algorithm> #include<cmath> #include<map> #include<utility> #include<vector> using namespace std; pair…
https://vjudge.net/problem/UVA-11991 题意:给出一个包含n个整数的数组,你需要回答若干询问.每次询问两个整数k和v,输出从左到右第k个v的下标. 思路: 把每个数字所出现的下标存储在vector中. #include<iostream> #include<string> #include<cstring> #include<algorithm> #include<vector> #include<map&…
题目链接 白书上的例题,关于vector的使用.不定长数组vector,类型内部封装了一些常用操作.vector就像一个二维数组,只有第一维的大小是固定的,可以像数组一样访问到其中的每一个元素. vector<int> v; 常用操作  v.size();  v.clear();清空 v.resize();改变大小  v.push_back();在尾部添加元素  v.pop_back();在尾部删除元素  v.empty();检测是否为空 vector之间可直接赋值或作为函数的返回值,像是“一…
题目大意:一个n个整数的数组,m条查询指令.(1<=n,m<=100 000)每次询问第k个整数v的下标值,若不存在输出0. #include<iostream> #include<map> #include<vector> #include<cstdio> using namespace std; map<int,vector<int> > a; int main() { int n,m,i,p,k,v; ) { a.c…
UVA 11991 - Easy Problem from Rujia Liu? 题目链接 题意:给一个长度n的序列,有m询问,每一个询问会问第k个出现的数字的下标是多少 思路:用map和vector搞,map[i][j]直接保存的就是数字i第j个出现,每次直接输出就可以 代码: #include <cstdio> #include <cstring> #include <vector> #include <map> using namespace std;…
UVa 101 The Blocks Problem 一道纯模拟题 The Problem The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are nblocks on the table (numbered from 0 to n-1) with block bi…
挺水的模拟题,刚开始题目看错了,poj竟然过了...无奈.uva果断wa了 搞清题目意思后改了一下,过了uva. 题目要求模拟木块移动: 有n(0<n<25)快block,有5种操作: move a onto b  在将a搬到b上之前,先把a和b上的积木放回原來的位置 move a over b在将a搬到b所在的那堆积木上前,先把a上的积木放回原來的位罝 pile a onto b 将包括a本身和上方的积木一起放到b上,在放之前b上方的积木放回原来的位置 pile a over b 将包括a本…
UVA - 1593 Alignment of Code Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description   题意:输入数行数据,一行数据多个短字符串,输出要按照每列最长的占位进行输出. 下面是具体显示效果(为了看清楚具体输出我把空格换成了"|") 输入: ------------------------------------…
思路: 容易知道加向量的顺序是按向量斜率的大小顺序来的.由于数据不是很大,可以用背包解决!! dp[i][j]:加入最大面积为i时,加入了j个向量. 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<set> #include<vector> #define ll…
I mean your borrowers of books--those mutilators of collections, spoilers of the symmetry of shelves, and creators of odd volumes. --Charles Lamb, Essays of Elia (1823) 'The Two Races of Men' Like Mr. Lamb, librarians have their problems with borrowe…
Foreign Exchange Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordinates a very successful foreign student exchange program. Over the last few years, demand has sky-rocketed and now you need assistance w…
https://vjudge.net/problem/UVA-10474 https://blog.csdn.net/xiyaozhe/article/details/81081344 简单用法 sort(start,end) 默认是升序 实现降序: #include <functional> int a[10]={5,6,7,8,9,0,1,2,3,4}; vector <int> v(a, a+10); sort(v.begin(), v.end(),less<int&g…
题意:一大堆单词中间有空格隔开,以'#'结束输出,问只出现一次的的单词有哪些(如果两个具有相同的长度,相同的字母也算是相同的,不区分大小写,如:noel和lone属于一个单词出现两次).最后按照字典序输出那些只出现一次的单词 #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <math.h> #include <l…
The only printer in the computer science students' union is experiencing an extremely heavy workload. Sometimes there are a hundred jobs in the printer queue and you may have to wait for hours to get a single page of output. Because some jobs are mor…
Ananagrams  Descriptions: Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute, no matter how you rearra…
The Blocks Problem Descriptions:(英语就不说了,直接上翻译吧) 初始时从左到右有n个木块,编号为0~n-1,要求实现下列四种操作: move a onto b: 把a和b上方的木块全部放回初始的位置,然后把a放到b上面 move a over b: 把a上方的木块全部放回初始的位置,然后把a放在b所在木块堆的最上方 pile a onto b: 把b上方的木块部放回初始的位置,然后把a和a上面所有的木块整体放到b上面 pile a over b: 把a和a上面所有…
Problem Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find and print the 1500’th ugly…
题目: 思路: dp[j][h]表示选取了j个向量,且高度为h,利用01背包来解决问题. 没选当前的向量:dp[j][h] = dp[j][h]; 选了当前的向量:dp[j][h] = dp[j-1][h-p[i].y]+2*p[i].x*(h-p[i].y)+p[i].area;(p[i].area = p[i].x+p[i].y) 代码: #include <bits/stdc++.h> #define inf 0x3f3f3f3f #define MAX 1000000000 #defi…
11991 - Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests likeXi’an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu’s Presents 1and 2), he occasionally sets easy…
题意: 给一段字符串成段染色,问染成目标串最少次数. SOL: 区间DP... DP[i][j]表示从i染到j最小代价 转移:dp[i][j]=min(dp[i][j],dp[i+1][k]+dp[k+1][j]); CODE: BZ: /*================================================================= # Created time: 2016-03-28 21:10 # Filename: uva4394.cpp # Desc…
题意:8个方向如果能够连成一块就算是一个连通块,求一共有几个连通块. 分析:网上的题解一般都是dfs,但是今天发现并查集也可以解决,为了方便我自己理解大神的模板,便尝试解这道题目,没想到过了... #include <cstdio> #include <iostream> #include <sstream> #include <cmath> #include <cstring> #include <cstdlib> #include…