#include <iostream>
#include <vector>
using namespace std;
struct vertex;
vector< vertex > t;
struct vertex {
int nxt;
vertex() {
nxt = 0;
}
int getNext() {
if( nxt == 0 ) {
cout << "t.size() = " << t.size() << endl;
nxt = t.size();
cout << "new nxt = " << nxt << endl;
t.push_back( vertex() );
}
cout << "nxt = " << nxt << endl;
return nxt;
}
};
int main() {
t.push_back( vertex() );
cout << t[0].getNext() << endl;
cout << t[0].getNext() << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKc3RydWN0IHZlcnRleDsKIAp2ZWN0b3I8IHZlcnRleCA+IHQ7CiAKc3RydWN0IHZlcnRleCB7CiAgICBpbnQgbnh0OwogICAgdmVydGV4KCkgewogICAgICAgIG54dCA9IDA7CiAgICB9CiAgICBpbnQgZ2V0TmV4dCgpIHsKICAgICAgICBpZiggbnh0ID09IDAgKSB7CiAgICAgICAgCWNvdXQgPDwgInQuc2l6ZSgpID0gIiA8PCB0LnNpemUoKSA8PCBlbmRsOwogICAgICAgICAgICBueHQgPSB0LnNpemUoKTsKICAgICAgICAgICAgY291dCA8PCAibmV3IG54dCA9ICIgPDwgbnh0IDw8IGVuZGw7CiAgICAgICAgICAgIHQucHVzaF9iYWNrKCB2ZXJ0ZXgoKSApOwogICAgICAgIH0KICAgICAgICBjb3V0IDw8ICJueHQgPSAiIDw8IG54dCA8PCBlbmRsOwogICAgICAgIHJldHVybiBueHQ7CiAgICB9Cn07CiAKaW50IG1haW4oKSB7CiAgICB0LnB1c2hfYmFjayggdmVydGV4KCkgKTsKICAgIGNvdXQgPDwgdFswXS5nZXROZXh0KCkgPDwgZW5kbDsKICAgIGNvdXQgPDwgdFswXS5nZXROZXh0KCkgPDwgZW5kbDsKIAogICAgcmV0dXJuIDA7Cn0=