Kickstart Round F 2018第一名Benq的参赛代码,光开头几行就把我吓得魂飞魄散。
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define sz(x) (int)(x).size()
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void io(string s = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
if (sz(s)) {
setIn(s+".in");
setOut(s+".out");
}
}
int main() {
io("A");
// ...
}
GCC Function Attributes
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
Common Function Attributes x86 Function Attributes
指定GCC做O3优化,支持SSE4指令。
bits/stdc++.h
这是一个“万能”头文件,涵盖了所有STL头文件,刷题够用了。
Policy Based Data Structure
属于STL扩展。
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
这段代码搞了一个set的扩展,让它支持find_by_order和order_of_key。你也可以修改一下第二个参数"null_type",让这个模板成为map的扩展,例如
template <class T1, T2> using Tree = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
注意,它们不支持多重值。
Rope
#include <ext/rope>
using namespace __gnu_cxx;
一个STL扩展,支持区间的插入、删除。
I/O
{ios_base::sync_with_stdio(0); cin.tie(0);}
取消C++与C的I/O缓冲的同步;取消cin与cout的“绑定”。