#include <iostream>
#include <vector>
typedef std::vector<std::vector<int>> PUD;
PUD MakeHoge(PUD& In){
PUD Ret;
for (std::size_t i = 0; i < In.size() - 1; i++){
Ret.push_back(std::vector<int>());
for (std::size_t j = 0; j < In[i].size();j++){
Ret[i].push_back(In[i][j]);
}
for (std::size_t j = 0; j < In[i].size();j++){
Ret[i].push_back(In[i+1][j]);
}
}
return std::move(Ret);//why std::move dosnt work??? on vc2013ee. because move to Temp object?
}
int main(){
PUD PU{ { 31 }, { 41 }, { 59 }, { 2 }, };
while (PU.size() != 1){
PU=MakeHoge(PU);
for (auto& v : PU){
std::cout << '(';
for (auto& i : v){
std::cout << i << ' ';
}
std::cout << ')';
}
std::cout << std::endl;
}
int Total = 0;
for (auto& i : PU) {
for (auto& j : i){
Total += j;
}
}
std::cout <<"Total="<< Total << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdHlwZWRlZiBzdGQ6OnZlY3RvcjxzdGQ6OnZlY3RvcjxpbnQ+PiBQVUQ7CgpQVUQgTWFrZUhvZ2UoUFVEJiBJbil7CglQVUQgUmV0OwoJZm9yIChzdGQ6OnNpemVfdCBpID0gMDsgaSA8IEluLnNpemUoKSAtIDE7IGkrKyl7CgkJUmV0LnB1c2hfYmFjayhzdGQ6OnZlY3RvcjxpbnQ+KCkpOwoJCWZvciAoc3RkOjpzaXplX3QgaiA9IDA7IGogPCBJbltpXS5zaXplKCk7aisrKXsKCQkJUmV0W2ldLnB1c2hfYmFjayhJbltpXVtqXSk7CgkJfQoJCWZvciAoc3RkOjpzaXplX3QgaiA9IDA7IGogPCBJbltpXS5zaXplKCk7aisrKXsKCQkJUmV0W2ldLnB1c2hfYmFjayhJbltpKzFdW2pdKTsKCQl9Cgl9CglyZXR1cm4gc3RkOjptb3ZlKFJldCk7Ly93aHkgc3RkOjptb3ZlIGRvc250IHdvcms/Pz8gb24gdmMyMDEzZWUuIGJlY2F1c2UgbW92ZSB0by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