- vectorの要素数は正しいですか? (足りなくてもエラーは出ないことがある)
- 関数の名前を変更しましたか?
- 添字は適切ですか?
- 組合せ列挙で自分を数え忘れていませんか?
- IO時にデータを正規化していますか?(0-idxed, 座標圧縮, グラフ構築)
- 半開区間を使っていますか?
- maxとminを間違えていませんか?
- 深さ優先探索でスタックオーバーフローしていませんか?
- 再帰関数内の条件分岐の順序は適切ですか?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cout.precision(16); | |
func int debug(mesh &Th) { | |
cout << "Nb of boundary elements: " << Th.nbe << ",\t" | |
<< "Nb of nodes: " << Th.nv << ",\t" | |
<< "Nb of triangles: " << Th.nt << ",\t" | |
<< "Area: " << Th.measure << "\n\n"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
int i = 0; | |
int const ci = 0; | |
int * pi; | |
pi = &i; | |
// pi = &ci; | |
int const * pci; | |
pci = &i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
template<typename T, typename... U> | |
using Fn = std::function<T(U...)>; | |
int add(int x, int y) { | |
return x + y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include<vector> | |
#include<algorithm> | |
#include<iterator> | |
int main() { | |
std::vector<int> v = {0,1,2,3,4}; | |
std::vector<int> w; | |
std::copy(v.begin() + 1, v.begin() + 4, std::back_inserter(w)); | |
for (int n : w) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-27) | |
(define (sample lst) | |
(list-ref lst (random-integer (length lst)))) | |
(define (assoc-all alist obj) | |
(map cdr | |
(filter (lambda (x) | |
(eq? (car x) obj)) | |
alist))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
namespace iota { | |
class Iter { | |
public: | |
Iter(): iter(0) {} | |
Iter(int x): iter(x) {} | |
int operator*() { | |
return iter; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> struct C {}; | |
template <template <typename T> class C> | |
class D { | |
C<int> cint; | |
C<double> cdouble; | |
}; | |
int main() { | |
D<C> d; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add() { | |
var id = document.getElementById("id").value; | |
add_friend(id); | |
} | |
function add_friend(id, conn) { | |
if (typeof conn == "undefined") { | |
conn = peer.connect(id); | |
} | |
connections[id] = conn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
typedef long long int lli; | |
const int INF = INT_MAX/3; | |
struct segment_tree { | |
int n; | |
vector<int> dat; |
NewerOlder