UVa 11991 Easy Problem from Rujia Liu?
2015-03-15 16:42
330 查看
水题。
给出一个数列,求第k个值为v的数字的位置。
熟练使用STL还是很有必要的,尤其是CF的Div用map用得挺多的。
代码君
给出一个数列,求第k个值为v的数字的位置。
熟练使用STL还是很有必要的,尤其是CF的Div用map用得挺多的。
#include <cstdio> #include <map> #include <vector> using namespace std; void scan(int& x) { char c; while(c = getchar(), c < '0' || c > '9'); x = c - '0'; while(c = getchar(), c >= '0' && c <= '9') x = x*10 + c - '0'; } const int maxn = 100000 + 10; int main() { //freopen("in.txt", "r", stdin); int n, m; while(scanf("%d%d", &n, &m) == 2) { map<int, vector<int> > pos; for(int i = 1; i <= n; i++) { int x; scan(x); pos[x].push_back(i); } for(int i = 0; i < m; i++) { int k, v; scan(k); scan(v); if(k <= pos[v].size()) printf("%d\n", pos[v][k-1]); else printf("0\n"); } } return 0; }
代码君
相关文章推荐
- (DS 《算法入门经典》)UVA 11991 Easy Problem from Rujia Liu?(求第k个v出现的索引)
- uva 11991 - Easy Problem from Rujia Liu?
- uva 11991 - Easy Problem from Rujia Liu?
- Uva-11991-Easy Problem from Rujia Liu?
- UVa 11991 - Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- uva 11991 Easy Problem from Rujia Liu? map+vector
- UVA - 11991 - Easy Problem from Rujia Liu? (STL)
- uva 11991 - Easy Problem from Rujia Liu?(STL)
- UVa 11991 - Easy Problem from Rujia Liu?
- Uva-11991 - Easy Problem from Rujia Liu?
- UVA - 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- UVA 11991 - Easy Problem from Rujia Liu?
- UVa 11991 Easy Problem from Rujia Liu?
- UVA - 11991 Easy Problem from Rujia Liu? map+vector
- uva 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- Uva 11991 - Easy Problem from Rujia Liu?
- UVA11991 Easy Problem from Rujia Liu?题解