三種堆分別是std::priority_queue pbds::priority_queue(pairing_heap_tag) zkw線段樹(加入了剪枝,即modify函式裡當兄弟節點的value比自己小的時候break,因為再往上的最小值肯定由兄弟節點貢獻)
為什麼沒有手寫的paring_heap和binary_heap?大概沒人會手寫吧 實際上是因為我不會
結論大概是
不開o2時的用時:zkw線段樹 < pbds::pq < std::pq
開o2時:std::pq 遠小於 zkw線段樹 < pbds::pq(稠密圖zkw線段樹的速度跟std::pq相近 且pbds::pq快於std::pq(因為點數較小所以實際差別並不大))
鬼知道std::pq吸氧以後為什麼會快那麼多
//gen
#include using namespace std;
const int maxn = 1e6+7;
vectorg[maxn];
inline void add(int u, int v)
char wbuf[50<<20], *p2 = wbuf;
inline void print(int x, int y, int z)
int main(void) while(u == v || binary_search(g[u].begin(), g[u].end(), v));
add(u, v);
} for(int i = 1; i <= n; ++i)
} fwrite(wbuf, 1, p2 - wbuf, stdout);
return 0;
}
//runner
#include using namespace std;
int cnt = 0;
int main(void)
return 0;
}
#include #include using namespace std;
using namespace __gnu_pbds;
#define mp make_pair
#define value first
#define mark second
const int maxn = 3e5 + 7;
#define lson (o<<1)
#define rson (o<<1|1)
typedef pairpii;
int dis[maxn], head[maxn], n, m, s, t, tot, vis[maxn];
struct zkwheap
inline void build(int n)
inline int tpos()
inline void modify(int pos, int val, bool flag)
} inline int pop()
} tree;
struct edge g[maxn << 2];
inline void add(int u, int v, int w) ; head[u] = tot;
}std::priority_queue, greater>q;
typedef __gnu_pbds::priority_queue, pairing_heap_tag> heap;
heap::point_iterator it[maxn];
heap q1;
unsigned long long ans[3];
void dijkstra(int s)
}} for (int i = 1; i <= n; ++i) ans[0] = (ans[0] + dis[i] * i);
}void dijkstra(int s)
}} for (int i = 1; i <= n; ++i) ans[1] = (ans[1] + dis[i] * i);
}void dijkstra(int s)
}} for (int i = 1; i <= n; ++i) ans[2] = (ans[2] + dis[i] * i);
}char buf[50 << 20], *p1 = buf;
inline void read(int &x, int &y, int &z)
int main(void)
double tim1 = clock();
dijkstra(1);
double tim2 = clock();
dijkstra(1);
double tim3 = clock();
dijkstra(1);
double tim4 = clock();
cerr << ans[0] << endl << ans[1] << endl << ans[2] << endl;
cerr << "std::pq " << (tim2 - tim1) << endl;
cerr << "pbds::pq " << (tim3 - tim2) << endl;
cerr << "zkwsgt " << (tim4 - tim3) << endl;
return 0;
}
三種傳奇語言的速度比較 3
b include include class nosuchelementexception class illegalstateexception class list class iter inline bool hasnext const inline int next element hea...
三種傳奇語言的速度比較 4
c created on 2005 3 21 author jtzhu using system internal class nosuchelementexception system.exception public class list internal class iter internal...
關於Hive的三種模式
hadoop權威指南 第二版 374頁這張圖 1.上方描述的是 內嵌模式 特點是 hive服務 和metastore服務 執行在同乙個程序中,derby服務也執行在該程序中。該模式無需特殊配置 2.中間是 本地模式 特點是 hive服務 和metastore服務 執行在同乙個程序中,mysql是單獨...