#include #include #include using namespace std; int n, m, peo[100]={0}, tes, poi, dea, tar; vector cmd[60], alive; vector::iterator result, tar2; int c(){ for(int i=0; i<55; i++){ cmd[i].clear(); } return 0; } int main() { cin >> n; for(int i=0; i> m; for(int j=0; j> peo[j]; if(peo[j]) poi=j; } for(int j=0; j> tes; cmd[j].push_back(tes); } result=find(alive.begin(), alive.end(), cmd[poi][0]); alive.erase(result); //poi=cmd[poi]=0; //if() //cout << *alive.end(); //if(find(alive.begin(), alive.end(), 87)==alive.end()) cout << "GGGG"; //return 0; dea=cmd[poi][0]-1; //cout << alive.size() << '\n'; while(1){ if(alive.size()<=2 || (find(alive.begin(), alive.end(), (poi+1))==alive.end())){ break; } for(vector::iterator it=cmd[dea].begin(); it!=cmd[dea].end(); it++){ tes=*it; //cout << tes << '\n'; if(find(alive.begin(), alive.end(), tes)!=alive.end()){ tar2=find(alive.begin(), alive.end(), tes); tar=*it; break; } } //cout << dea << ' ' << tar << '\n'; //cout << *tar2 << '\n'; alive.erase(tar2); dea=tar-1; } /* for(int i=0; i