STL的应用 multiset bitset next_permutation
2011-09-04 18:19
369 查看
multiset的应用 toj 2196 Nuanran's Idol II
multiset的应用 uestc1224 合并果子
bitset的应用 poj 2443 Set Operation
next_permutaion的用法 poj 1256 Anagram
/* * toj2196.cpp * * Created on: 2011-9-4 * Author: bjfuwangzhu */ #include<iostream> #include<stdio.h> #include<set> #include<algorithm> #include<functional> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int n, i, num; char c; multiset<int, less<int> > mset; while (scanf("%d", &n) != EOF,n) { mset.clear(); for (i = 0; i < n; i++) { scanf(" %c", &c); if (c == 'B') { scanf("%d", &num); mset.insert(num); } else { printf("%d\n", *mset.begin()); mset.erase(mset.begin()); } } } return 0; }
multiset的应用 uestc1224 合并果子
/* * uestc1224.cpp * * Created on: 2011-9-4 * Author: bjfuwangzhu */ #include<iostream> #include<algorithm> #include<stdio.h> #include<set> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif multiset<int> mset; int n, i, num, res, temp, numa, numb; while (scanf("%d", &n) != EOF) { mset.clear(); for (i = 0; i < n; i++) { scanf("%d", &num); mset.insert(num); } res = 0; while (mset.size() != 1) { numa = *mset.begin(); mset.erase(mset.begin()); numb = *mset.begin(); mset.erase(mset.begin()); temp = numa + numb; res += temp; mset.insert(temp); } printf("%d\n", res); } return 0; }
bitset的应用 poj 2443 Set Operation
/* * poj2443.cpp * * Created on: 2011-9-4 * Author: bjfuwangzhu */ #include<iostream> #include<stdio.h> #include<bitset> using namespace std; const int N = 1001; const int nmax = 10001; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int N, i, j, C, Q, num, nnum, k; while (scanf("%d", &N) != EOF) { bitset<nmax> bset ; for (i = 0; i < N; i++) { scanf("%d", &C); for (j = 0; j < C; j++) { scanf("%d", &num); bset[i].set(num); } } scanf("%d", &Q); for (i = 0; i < Q; i++) { scanf("%d %d", &num, &nnum); for (j = 0, k = 1; j < N; j++) { if (bset[j].test(num) && bset[j].test(nnum)) { puts("Yes"); k = 0; break; } } if (k) { puts("No"); } } } return 0; }
next_permutaion的用法 poj 1256 Anagram
/* * poj1256.cpp * * Created on: 2011-9-4 * Author: bjfuwangzhu */ #include<algorithm> #include<ctype.h> #include<stdio.h> #include<string.h> using namespace std; const int nmax = 14; int cmp(const char &a, const char &b) { if (a == b || (b - a) == 32 || (b - a) == 32) { return a < b; } return toupper(a) < toupper(b); } int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int T, i, clen; char ch[nmax]; while (scanf("%d", &T) != EOF) { for (i = 0; i < T; i++) { scanf("%s", ch); clen = strlen(ch); sort(ch, ch + clen, cmp); do { puts(ch); } while (next_permutation(ch, ch + clen, cmp)); } } return 0; }
相关文章推荐
- HDU 1027 STL中next_permutation的应用
- 7.2.1 生成1~n的排列(全排列)【STL__next_permutation()_的应用】
- 【C++ STL应用与实现】62: 如何使用std::next_permutation
- STL中next_permutation用法小结和小技巧总结与原理。
- POJ1833 排列(next_permutation()的应用)
- 【STL】全排列生成算法:next_permutation
- STL之 next_permutation
- 计算下一个全排列(以STL中的next_permutation为例)
- 枚举全排列 STL next_permutation
- HDU 1027 Ignatius and the Princess II【STL- next_permutation全拍列】
- STL全排列(next_permutation(str,str+length))and Java全排列
- STL 源代码剖析 算法 stl_algo.h -- next_permutation
- 素数环 南工acm(STL:next_permutation)
- HOJ 1191 (next_permutation()的应用)
- poj-1833-排列 stl next_permutation(a,a+n)
- stl算法:next_permutation剖析
- HDU-1027 组合数 STL-next_permutation
- stl全排列 qsort+next_permutation(a,a+n) -->全排列
- STL里面的next_permutation求字典序排列问题
- Backward Digit Sums(poj3187)(STL next_permutation运用)