在 OS X 中安裝 GNU GCC 以及使用 bits/stdc++.h 头文件 Policy-Based Data Structure

来源:互联网 发布:iphone蜂窝数据开关 编辑:程序博客网 时间:2024/06/01 07:50

系统环境

OS X:10.9

Homebrew: 0.9.5

Xcode : 5.0.2


#include <bits/std ++>相当于引入下面所有的标准函数库

#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>


程序快速编辑模板:

#include <bits/stdc++.h>#define _ ios_base::sync_with_stdio(0);cin.tie(0);using namespace std;int main() { _return 0;}
pb_ds: 全名[Policy-Based Data Structure]包含了各种容器,如tree 、hash table、heap以及list等结果
tree 实现STL map的范例
#include <iostream>#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>using namespace std;using namespace __gnu_pbds;typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> map_t;int main() {int n;while (~scanf("%d", &n)) {map_t s;for (int i = 0; i < n; ++i) {int k, v;scanf("%d %d", &k, &v);s.insert(pair<int, int>(k, v));}for (int i = 0; i < n; ++i) {printf("%d: %d\n", s.find_by_order(i)->first, s.find_by_order(i)->second);}}return 0;}
原博客地址:http://blog.kuoe0.tw/posts/2014/01/31/install-gnu-gcc-on-os-x-and-use-the-header-bits-stdcplusplus-h-and-policy-based-data-structure/

0 0
原创粉丝点击