forked from beet-aizu/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvec.cpp
39 lines (34 loc) · 843 Bytes
/
cvec.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T,size_t... es>
struct Vec{
T v;
T* begin(){return *v;};
T* end(){return (*v)+1;};
void fill(T x){v=x;};
T& operator=(T x){return v=x;};
operator T&(){return v;};
};
template<typename T,size_t e,size_t... es>
struct Vec<T,e,es...> : array<Vec<T, es...>, e> {
Vec<T,e,es...>(){};
Vec<T,e,es...>(T x){fill(x);};
using array<Vec<T, es...>, e>::begin;
using array<Vec<T, es...>, e>::end;
void fill(T x){for(auto a=begin();a!=end();++a) a->fill(x);};
};
//END CUT HERE
//INSERT ABOVE HERE
signed main(){
auto v=Vec<int,10,10>();
v.fill(-1);
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
v[i][j]=i+j;
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
cout<<v[i][j]<<" \n"[j==9];
return 0;
}