- 论坛徽章:
- 11
|
本帖最后由 Susake_ 于 2014-09-10 21:36 编辑
回复 24# ID好难
他不是学生~
顺便发段代码,数据结构形式没搞出来,不过扩展库里面的貌似弄出来了
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/priority_queue.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #include <ext/pb_ds/trie_policy.hpp>
- std::priority_queue <int> pr_q;__gnu_pbds::trie <std::string, int> trie_t;
- __gnu_pbds::tree <int, int, std::less<int>, __gnu_pbds::splay_tree_tag, __gnu_pbds::tree_order_statistics_node_update> sp_t;
- __gnu_pbds::priority_queue<std::pair <int, int>,std::greater<std::pair <int, int> >, __gnu_pbds::pairing_heap_tag > pa_h;
- int main(int argc, char *argv[])
- {
- sp_t[1] = 1;///0下标,为1的有一个
- sp_t[2] = 1;///1下标,为2的有一个
- sp_t[3] = 2;///2下标,为3的有两个
- sp_t[5] = 1;///3下标,为5的有一个
- int sum = 0;
- int key = 5;///查询比key大的个数
- for(int i = sp_t.order_of_key(key) + 1; i < sp_t.size(); i++)///从查找的元素的后一个序列开始
- sum += sp_t[sp_t.find_by_order(i) -> first];
- printf("%d\n", sum);
- return 0;
- }
复制代码 |
|