#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<vector> usingnamespace std; #define MAXN 300006 int n , m , k; int A[MAXN]; vector<int> ans; intmain(){ cin >> n >> m >> k; for( int i = 1 ; i <= k ; ++ i ) scanf("%d",&A[i]); int lef = n - k; for( int i = 1 ; i <= k ; ++ i ) { int cur = m; while( lef && cur > A[i] ) ans.push_back(cur), -- cur ,-- lef; ans.push_back( A[i] ); } if( lef ) returnputs("No") , 0; puts("Yes"); for( auto it : ans ) printf("%d ",it); }
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<queue> usingnamespace std; #define MAXN 1006 #define pii pair<int,int> #define fi first #define se second #define mp make_pair int n , m , cnt; int deg[MAXN] , G[MAXN][MAXN]; queue<pii> Q; voidbfs( int x ){ for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (!G[i][j] && deg[i] + deg[j] >= x) Q.push(make_pair(i, j)), G[i][j] = G[j][i] = 1; while (!Q.empty()) { pii now = Q.front(); Q.pop(); ++ deg[now.fi] , ++ deg[now.se]; ++ cnt; int u = now.first, v = now.second; for (int i = 1; i <= n; i++) if (i != u && !G[u][i] && deg[u] + deg[i] >= x) G[u][i] = G[i][u] = 1 , Q.push(mp(u, i)); for (int i = 1; i <= n; i++) if (i != v && !G[v][i] && deg[v] + deg[i] >= x) G[v][i] = G[i][v] = 1 , Q.push(mp(v, i)); } } intmain(){ cin >> n >> m; for (int i = 1 , u , v; i <= m; ++ i) scanf("%d%d", &u, &v) , deg[u]++, deg[v]++ , G[u][v] = G[v][u] = 1 , cnt++; int all = n * ( n - 1 ) / 2; for (int i = 2 * n; i >= 0; -- i) { bfs( i ); if (cnt == all) returnprintf("%d\n", i) , 0; } }