23dfcca431 2011-02-23 kinaba: // Tested: SRM 454 Lv2 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP2 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: const int N1, N2; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP2(int N1, int N2, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(N1), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2) 23dfcca431 2011-02-23 kinaba: { return data[ (i1*N2)+i2 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP2& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 3d2bcff745 2011-12-29 kinaba: // Tested: Codeforces #13 C, SRM 528 Lv2 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP2x 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: const int N1, N2; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP2x(int, int N2, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(2), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2) 23dfcca431 2011-02-23 kinaba: { i1&=1; return data[ (i1*N2)+i2 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP2x& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: // Tested: SRM 452 Lv3 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP3 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP3(int N1, int N2, int N3, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(N1), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3) 23dfcca431 2011-02-23 kinaba: { return data[ ((i1*N2)+i2)*N3+i3 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP3& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: // Tested: SRM 468 Lv2 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP3x 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP3x(int, int N2, int N3, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(2), N2(N2), N3(N3), data(N1*N2*N3, t) { assert(data.size()*sizeof(T) < (1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3) 23dfcca431 2011-02-23 kinaba: { i1&=1; return data[ ((i1*N2)+i2)*N3+i3 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP3x& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: a01c3ec3ed 2011-10-04 kinaba: // Tested: SRM 520 Lv2 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP4 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3, N4; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP4(int N1, int N2, int N3, int N4, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(N1), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3, int i4) 23dfcca431 2011-02-23 kinaba: { return data[ (((i1*N2)+i2)*N3+i3)*N4+i4 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP4& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: // Not Tested 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP4x 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3, N4; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP4x(int, int N2, int N3, int N4, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(2), N2(N2), N3(N3), N4(N4), data(N1*N2*N3*N4, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3, int i4) 23dfcca431 2011-02-23 kinaba: { i1&=1; return data[ (((i1*N2)+i2)*N3+i3)*N4+i4 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP4x& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: // Tested: SRM 351 Lv2 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP5 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3, N4, N5; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP5(int N1, int N2, int N3, int N4, int N5, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(N1), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3, int i4, int i5) 23dfcca431 2011-02-23 kinaba: { return data[ ((((i1*N2)+i2)*N3+i3)*N4+i4)*N5+i5 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP5& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: }; 23dfcca431 2011-02-23 kinaba: 23dfcca431 2011-02-23 kinaba: // Not Tested 23dfcca431 2011-02-23 kinaba: template<typename T> 23dfcca431 2011-02-23 kinaba: struct DP5x 23dfcca431 2011-02-23 kinaba: { 23dfcca431 2011-02-23 kinaba: int N1, N2, N3, N4, N5; 23dfcca431 2011-02-23 kinaba: vector<T> data; 23dfcca431 2011-02-23 kinaba: DP5x(int, int N2, int N3, int N4, int N5, const T& t = T()) ad9e7615bd 2013-12-15 kinaba: : N1(2), N2(N2), N3(N3), N4(N4), N5(N5), data(N1*N2*N3*N4*N5, t) { assert(data.size()*sizeof(T)<(1<<28)); } 23dfcca431 2011-02-23 kinaba: T& operator()(int i1, int i2, int i3, int i4, int i5) 23dfcca431 2011-02-23 kinaba: { i1&=1; return data[ ((((i1*N2)+i2)*N3+i3)*N4+i4)*N5+i5 ]; } 23dfcca431 2011-02-23 kinaba: void swap(DP5x& rhs) 23dfcca431 2011-02-23 kinaba: { data.swap(rhs.data); } 23dfcca431 2011-02-23 kinaba: };