STL

ID

線形代数と固有値問題 ひととおり線形代数を学んだ後によむといいかもしれない。できれば、関数解析をちょっとやった後で。スペクトル分解とかの所は結構細かいところまで乗ってるので便利。へぇ、こんな方法でとけるのか、と。でも説明丁寧かといわれるとそ…

ID

単語 rank3::1~~4 --> http://d.hatena.ne.jp/kenta11626918/20111012/1318401749 rank2 --> http://d.hatena.ne.jp/kenta11626918/20111006/1317882668 rank1 -->http://d.hatena.ne.jp/kenta11626918/20111017/1318821771 C34CAFDF85FFCEB9929CD40BD14E730…

#include listまとめ。

TopCoderではvector一辺倒でなにかと使わないlistですが、カードシャッフル等の操作をするときとかはかなり便利です. explicit list( size_type 長さ, const T& 値 = T() ); //イテレータでの初期化ももちろん可能. list& operator=(const list& c2); bool…

#include  空間、座標への対処

二次元座標を簡潔に書くのによさそう.コンストラクタ public member function complex (const T& re = T(), const T& im = T()); complex (const complex& cmplx); template complex (const complex& cmplx); // complex first (2.0,2.0); http://na-inet.j…

IO関連

sscanfでは[;]とかが無視されてしまう. sscanf(str.c_str(), "var see_ok_%s = %s;", word, flag); flag = ~~~;ってついちゃう. getline string型の欄にgetlineがある。http://www.cppreference.com/wiki/jp/io/getline #include istream& std::getline( i…

STL #include vector のまとめ。

元々の定義はこんな感じ. vector(); vector( const vector& c ); explicit vector( size_type num, const T& val = T() ); vector( input_iterator start, input_iterator end ); vector test(sz); //sz:要素数 vector test(sz, 0) //五個の要素を0で初期化…

STL #include stringのまとめ。

以外と曖昧なコンストラクタの実験から. string ( ); string ( const string& str ); string ( const string& str, size_t pos, size_t n = npos ); string ( const char * s, size_t n ); //Content is initialized to a copy of the string formed by the…

オペレータ

class LessInt { public: bool operator()(const int& riLeft, const int& riRight) const { return riLeft ()); //と、あたかも、コンストラクタを呼び出しているがごとく見える. sort(a.begin(), a.end(), cmp) // このとき、クラスは入れ子にできるよ. …

Member Pilot Round1 div2 medium

なかなか面白い問題で、人によって解き方多少違うと思う. 自分は(練習のために)キューを使いました.というか、キュー使わないと計算量がひどくなりそう. e.g) A B C ERDOS B D D E F G ans:: A:1 B:1 C:1 D:2 E:3 F:3 G ERDOS:0 vector calculateNumber…

関数アダプタ

bind2nd, bind1st :第一引数、第二引数を固定。 count_ifなどの..._if系統 template typename iterator_traits::difference_type count_if( InputIterator first, InputIterator last, UnaryPredicate p ); transform template OutputIterator transform( In…

bitset使ってみた. combination::nCrの列挙

がんばって、Combinationの列挙をしてみた. #include #include #include #include #include using namespace std; long long mypow(int k, int n) { long long ans = 1; for(int i = 0; i > comb; long long sz = mypow(2, N); int begin = (1 tmp(i); vect…

sortの使い方

#include template void sort( RandomAccessIterator start, RandomAccessIterator end ); template void sort( RandomAccessIterator start, RandomAccessIterator end, Compare cmp ); 構造体をソートするには、 vectorType> c; bool cmp(const Type& a, c…

#include

for_each 便利そうだけど当分使いそうもない。 template UnaryFunction for_each( InputIterator first, InputIterator last, UnaryFunction f ); template struct increment : public unary_function { //継承してる void operator()(T& x) { x++; } }; //x…

findの使い方

まずはfindから。 string型には、もう定義されてる #include size_type find( const string& str, size_type index = 0 ) const; size_type find( const charT* str, size_type index = 0 ) const; size_type find( const charT* str, size_type index, size…

SRM 471 div2 500

Problem Statement Elly is great fan of consistency. She would like to have order in even the simplest things in life – like listening to music. She has chosen several songs from which she wants to compose a playlist. The names of these son…

#include map, set

mapを使う機会は余りなさそうだけど.よく使う場面が人物(string型)と数字を関連させたい時. table表を作って動的計画法を行なう時とかにも結構大きな効果がある. 一番いいところはtableにすると見やすいところ.そして何より、 //aaaaaaは初めていれる文…

SRM167 div2 500

問題文 A collection of particles is contained in a linear chamber. They all have the same speed, but some are headed toward the right and others are headed toward the left. These particles can pass through each other without disturbing the…

STL #define vector のまとめ。

元々の定義はこんな感じ. vector(); vector( const vector& c ); explicit vector( size_type num, const T& val = T() ); vector( input_iterator start, input_iterator end ); vector test(sz); //sz:要素数 vector test(sz, 0) //五個の要素を0で初期化…

C言語的文字列操作の復習

#include 大文字,小文字 islower(ch); isupper(ch); 数字 isdigit(ch); int ->string型に. #include #include string IntToString(int number) { string stream ss; //ss(string型)なので、int型であるnumberで初期化できない×ss(number) //[ number; retur…

STLコンポーネント

コンテナ vectorとか 汎用アルゴリズム #include 反復子 iterator vector::iterator the_iterator; 関数オブジェクト #inculude アダプタ vector::reverse_iterator rit 割り当て子 allocator イテレータのカテゴリ内容提供元使える演算子 input_iterator(入…

listの個数の挙動

list list1(26, 'x'); cout while(!list1.empty()) { cout と、 cout for(int i = 0; i { cout は違うんだぜ. 二つ目のはsize()がループするごとにどんどん可変的に減っていくので、ちょうど半分で出力が止まってしまうのです.

pair ヘッダファイル

pairは2つの値をペアにして1つとして扱うためのクラス。 template struct pair { typedef T1 first_type; typedef T2 second_type; T1 first; T2 second; pair() : first(T1()), second(T2()) {} pair(const T1& x, const T2& y) : first(x), second(y) {}…