edo1z blog

プログラミングなどに関するブログです

2020-03-08から1日間の記事一覧

C++ clock

C++

C++で時間計測したいときはclock()が使えます。 参考:clock コードサンプル #include <bits/stdc++.h> #include <unistd.h> using namespace std; int main() { cout << "CLOCKS_PER_SEC: " << CLOCKS_PER_SEC << endl; clock_t start = clock(); cout << "start: " << start << endl</unistd.h></bits/stdc++.h>…

C++ ワーシャルフロイド法

参考:素人によるワーシャルフロイド法 - Qiita グラフ コード #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; const int INF = 1e9; void warshall_floyd(Graph &G) { int n = G.size(); for (int k = 0; k < n; ++k) { fo</vector<int></bits/stdc++.h>…

C++ ダイクストラ法

blog.logicky.com 上記はPythonでやっていました。C++でやってみます。 参考: 最短経路問題(ダイクストラ法) 対象のグラフ コード #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; const int INF = 1e9; int n = 8; // 頂点</vector<int></bits/stdc++.h>…

C++ ヒープ (priority_queue)

優先度つきキューは、何をどういう順序で入れても、優先順位の高いものから順に取り出すことができるキューです。内部的にはヒープを使って実装されます。C++では、priority_queueというのがあります。 コード int main() { priority_queue<int> que; que.push(1)</int>…