Overview
SHA1 Hash: | ad9e7615bd70b0d64b2b8f3f7aaacb3ac191b1ec |
---|---|
Date: | 2013-12-15 07:31:02 |
User: | kinaba |
Comment: | 256MB |
Timelines: | family | ancestors | descendants | both | trunk |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [9165bd3629]
- sym-trunk inherited from [9165bd3629]
Changes
Modified lib/typical/dp.cpp from [feb5fdb1e50b8e31] to [3e3b37ddf9926aec].
1 1 // Tested: SRM 454 Lv2 2 2 template<typename T> 3 3 struct DP2 4 4 { 5 5 const int N1, N2; 6 6 vector<T> data; 7 7 DP2(int N1, int N2, const T& t = T()) 8 - : N1(N1), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<26)); } 8 + : N1(N1), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<28)); } 9 9 T& operator()(int i1, int i2) 10 10 { return data[ (i1*N2)+i2 ]; } 11 11 void swap(DP2& rhs) 12 12 { data.swap(rhs.data); } 13 13 }; 14 14 15 15 // Tested: Codeforces #13 C, SRM 528 Lv2 16 16 template<typename T> 17 17 struct DP2x 18 18 { 19 19 const int N1, N2; 20 20 vector<T> data; 21 21 DP2x(int, int N2, const T& t = T()) 22 - : N1(2), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<26)); } 22 + : N1(2), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23 23 T& operator()(int i1, int i2) 24 24 { i1&=1; return data[ (i1*N2)+i2 ]; } 25 25 void swap(DP2x& rhs) 26 26 { data.swap(rhs.data); } 27 27 }; 28 28 29 29 // Tested: SRM 452 Lv3 30 30 template<typename T> 31 31 struct DP3 32 32 { 33 33 int N1, N2, N3; 34 34 vector<T> data; 35 35 DP3(int N1, int N2, int N3, const T& t = T()) 36 - : N1(N1), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T)<(1<<26)); } 36 + : N1(N1), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T)<(1<<28)); } 37 37 T& operator()(int i1, int i2, int i3) 38 38 { return data[ ((i1*N2)+i2)*N3+i3 ]; } 39 39 void swap(DP3& rhs) 40 40 { data.swap(rhs.data); } 41 41 }; 42 42 43 43 // Tested: SRM 468 Lv2 44 44 template<typename T> 45 45 struct DP3x 46 46 { 47 47 int N1, N2, N3; 48 48 vector<T> data; 49 49 DP3x(int, int N2, int N3, const T& t = T()) 50 - : N1(2), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T) < (1<<26)); } 50 + : N1(2), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T) < (1<<28)); } 51 51 T& operator()(int i1, int i2, int i3) 52 52 { i1&=1; return data[ ((i1*N2)+i2)*N3+i3 ]; } 53 53 void swap(DP3x& rhs) 54 54 { data.swap(rhs.data); } 55 55 }; 56 56 57 57 // Tested: SRM 520 Lv2 58 58 template<typename T> 59 59 struct DP4 60 60 { 61 61 int N1, N2, N3, N4; 62 62 vector<T> data; 63 63 DP4(int N1, int N2, int N3, int N4, const T& t = T()) 64 - : N1(N1), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<26)); } 64 + : N1(N1), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<28)); } 65 65 T& operator()(int i1, int i2, int i3, int i4) 66 66 { return data[ (((i1*N2)+i2)*N3+i3)*N4+i4 ]; } 67 67 void swap(DP4& rhs) 68 68 { data.swap(rhs.data); } 69 69 }; 70 70 71 71 // Not Tested 72 72 template<typename T> 73 73 struct DP4x 74 74 { 75 75 int N1, N2, N3, N4; 76 76 vector<T> data; 77 77 DP4x(int, int N2, int N3, int N4, const T& t = T()) 78 - : N1(2), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<26)); } 78 + : N1(2), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<28)); } 79 79 T& operator()(int i1, int i2, int i3, int i4) 80 80 { i1&=1; return data[ (((i1*N2)+i2)*N3+i3)*N4+i4 ]; } 81 81 void swap(DP4x& rhs) 82 82 { data.swap(rhs.data); } 83 83 }; 84 84 85 85 ................................................................................ 86 86 // Tested: SRM 351 Lv2 87 87 template<typename T> 88 88 struct DP5 89 89 { 90 90 int N1, N2, N3, N4, N5; 91 91 vector<T> data; 92 92 DP5(int N1, int N2, int N3, int N4, int N5, const T& t = T()) 93 - : N1(N1), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<26)); } 93 + : N1(N1), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<28)); } 94 94 T& operator()(int i1, int i2, int i3, int i4, int i5) 95 95 { return data[ ((((i1*N2)+i2)*N3+i3)*N4+i4)*N5+i5 ]; } 96 96 void swap(DP5& rhs) 97 97 { data.swap(rhs.data); } 98 98 }; 99 99 100 100 // Not Tested 101 101 template<typename T> 102 102 struct DP5x 103 103 { 104 104 int N1, N2, N3, N4, N5; 105 105 vector<T> data; 106 106 DP5x(int, int N2, int N3, int N4, int N5, const T& t = T()) 107 - : N1(2), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<26)); } 107 + : N1(2), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<28)); } 108 108 T& operator()(int i1, int i2, int i3, int i4, int i5) 109 109 { i1&=1; return data[ ((((i1*N2)+i2)*N3+i3)*N4+i4)*N5+i5 ]; } 110 110 void swap(DP5x& rhs) 111 111 { data.swap(rhs.data); } 112 112 };