2013-03-04から1日間の記事一覧

AOJ 0516 - Maximum Sum

aoj

#include<iostream> const int MAX_N = 1 << 18, INF = 1 << 24; class SegmentTree{ public: SegmentTree(int _n){ n = 1; while(n < _n)n *= 2; for(int i=0;i<2*n-1;i++){ data[i] = 0; } } void add(int k, int a){ k += n - 1; data[k] = a; while(k > 0){ k = (k</iostream>…

AOJ 0560 - Planetary Exploration

aoj

久しぶりに番兵法を用いました. 方針はdp[y][x][t]を(y, x')()で地形がtとなる個数とします. すると,(x1, y) (x2, y)間()の地形tの個数はdp[y][x2] - dp[y][x1-1]となります.((1, 1)起点なので負になりません.嬉しいですね) (x1, y1) (x2, y2)間ではyを…

AOJ 1051 - Citation Format

aoj

書くだけ #include<iostream> #include<vector> struct Pages{ int first, last; }; std::vector<Pages> v; void add(int n){ for(int i=0;i</pages></vector></iostream>

AOJ 0268 - Kongo Type

aoj

全体的に疲れる.特に小数の処理が疲れます. 今,短くしています. #include<iostream> #include<algorithm> #include<iomanip> std::string to2(char c16){ if(c16 == '0')return "0000"; if(c16 == '1')return "0001"; if(c16 == '2')return "0010"; if(c16 == '3')return "0011"; if(c1</iomanip></algorithm></iostream>…