bool solve() { int mg,mm; while(!g.empty() && !m.empty()) { mg=*g.begin(); mm=*m.begin(); if(mg<mm) g.erase(g.begin()); else m.erase(m.begin()); } return m.empty(); }
int main(){ int N, n; int count= 0; scanf( "%d", &N ); for( int i= 1; i<= N; ++i ) toWrite.insert( i ); for( int i= 1; i<= N; ++i ){ scanf( "%d", &arr[i] ); if( !freq[arr[i]] ) toWrite.erase( arr[i] ); freq[arr[i]]++; } //for( auto it= toWrite.begin(); it!= toWrite.end(); ++it ) // cout << *it << " "; //cout << endl; for( int i= 1; i<= N; ++i ){ auto it= num.insert( arr[i] ); if( !it.ss || arr[i] > N ){ arr[i]= *(toWrite.begin()); toWrite.erase( arr[i] ); } } for( int i= 1; i<= N; ++i ) cout << arr[i] << " "; return 0; }
int main() { int n,m,x,y,i; while(scanf("%d%d", &n, &m)!=EOF) { vs.clear(); for(i=0; i<n; ++i) v[i].clear(); for(i=0; i<m; ++i) { scanf("%d%d", &x, &y); --x; --y; v[x].push_back(y); v[y].push_back(x); } for(i=0; i<n; ++i) { s1.insert(i); sort(v[i].begin(), v[i].end()); } while(!s1.empty()) { x=*s1.begin(); s1.erase(x); s2.clear(); q.push(x); while(!q.empty()) { x=q.front(); q.pop(); s2.insert(x); for(sit=s1.begin(); sit != s1.end();) { y=*sit; ++sit; if(!binary_search(v[x].begin(), v[x].end(), y)) { q.push(y); s1.erase(y); } } } vs.push_back(s2); } printf("%u\n", vs.size()); for(i=0; i<vs.size(); ++i) { printf("%u", vs[i].size()); for(sit=vs[i].begin(); sit != vs[i].end(); ++sit) { printf(" %d", *sit+1); } puts(""); } } return 0; }