A - Cover it!

原题链接:http://codeforces.com/problemset/problem/1176/E

You are given an undirected unweighted connected graph consisting of nn vertices and mm edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.

Your task is to choose at most ⌊n2⌋⌊n2⌋ vertices in this graph so each unchosen vertex is adjacent (in other words, connected by an edge) to at least one of chosen vertices.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

You will be given multiple independent queries to answer.

Input

The first line contains a single integer tt (1≤t≤2⋅1051≤t≤2⋅105) — the number of queries.

Then tt queries follow.

The first line of each query contains two integers nn and mm (2≤n≤2⋅1052≤n≤2⋅105, n−1≤m≤min(2⋅105,n(n−1)2)n−1≤m≤min(2⋅105,n(n−1)2)) — the number of vertices and the number of edges, respectively.

The following mm lines denote edges: edge ii is represented by a pair of integers vivi, uiui (1≤vi,ui≤n1≤vi,ui≤n, ui≠viui≠vi), which are the indices of vertices connected by the edge.

There are no self-loops or multiple edges in the given graph, i. e. for each pair (vi,uivi,ui) there are no other pairs (vi,uivi,ui) or (ui,viui,vi) in the list of edges, and for each pair (vi,uivi,ui) the condition vi≠uivi≠ui is satisfied. It is guaranteed that the given graph is connected.

It is guaranteed that ∑m≤2⋅105∑m≤2⋅105 over all queries.

Output

For each query print two lines.

In the first line print kk (1≤⌊n2⌋1≤⌊n2⌋) — the number of chosen vertices.

In the second line print kk distinct integers c1,c2,…,ckc1,c2,…,ck in any order, where cici is the index of the ii-th chosen vertex.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

Example

Input

2
4 6
1 2
1 3
1 4
2 3
2 4
3 4
6 8
2 5
5 4
4 3
4 1
1 3
2 3
2 6
5 6

Output

2
1 3
3
4 3 6

题意:给你一个图要你选边(边数最多为n/2向下取整)但有个要求就是如果选了a边,那么必须要有一条没有选的b边。

思路:这是一个经典的染色问题,我们把选的边用1标记,没选的边用0标记即可。作一次图的遍历相邻的边用不同的颜色染色。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#define LL long long

using namespace std;
const int maxn=2e5+100;

struct node
{
    int to,Next;
};

node Edge[2*maxn];
int Head[maxn];
int tot[maxn];
int cnt;
int gg0,gg1;
int vis[maxn];
int n,m;
void add(int u,int v)
{
    Edge[++cnt].to=v;
    Edge[cnt].Next=Head[u];
    Head[u]=cnt;
    return ;
}
void dfs(int x,int jb)
{
    vis[x]=jb;

    for(int i=Head[x];i!=-1;i=Edge[i].Next)
    {
        int v=Edge[i].to;
        if(vis[v]==-1)
            dfs(v,jb^1);
    }
    return ;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=0;i<=n;i++)
        {
            Head[i]=-1;
        }
        for(int i=1;i<=n;i++)
        {
            vis[i]=-1;
        }
        cnt=0;
        for(int i=1;i<=m;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            add(u,v);
            add(v,u);
        }
        gg1=0;
        gg0=0;
        dfs(1,0);
        for(int i=1;i<=n;i++)
        {
            if(vis[i])
            {
                gg1++;
            }
            else
            {
                gg0++;
            }
        }
        if(gg0>gg1)
        {
            printf("%d\n",gg1);
            for(int i=1;i<=n;i++)
            {
                if(vis[i]==1)
                {
                    printf("%d ",i);
                }
            }
            printf("\n");
        }
        else
        {
            printf("%d\n",gg0);
            for(int i=1;i<=n;i++)
            {
                if(vis[i]==0)
                {
                    printf("%d ",i);
                }
            }
            printf("\n");
        }
    }
    return 0;
}

最后:这个题也可以BFS分层遍历和染色的想法类似。

### CH341A DKMS Driver Installation and Configuration For systems requiring the use of USB-to-serial converters, particularly those based on the CH340 or CH341 chipset like the CH341A, installing a compatible driver is essential to ensure proper functionality. The following details cover how one might go about setting up such drivers using DKMS (Dynamic Kernel Module Support), which allows for automatic rebuilding of kernel modules when new kernels are installed. #### Installing Dependencies Before proceeding with the installation of any third-party drivers including those for devices utilizing the CH341A chip, it's important that certain dependencies be present within the system environment. These typically involve development tools as well as headers specific to the Linux distribution being used. ```bash sudo apt-get update && sudo apt-get install -y build-essential linux-headers-$(uname -r) ``` #### Obtaining the CH341A Driver Source Code The source code necessary for building the CH341A driver can often be found through various repositories online; however, an official package from WCH (WinChipHead) may not always exist in all distributions' default software sources. One approach involves downloading precompiled binaries or fetching the latest version directly from GitHub projects dedicated to maintaining these drivers[^1]. Once obtained, extract the archive into a suitable directory before continuing further steps related to compilation and integration via DKMS. #### Setting Up DKMS Environment DKMS facilitates managing out-of-tree kernel modules by automatically recompiling them whenever there’s a change in the running kernel. To set this up specifically for the CH341A device: 1. Install `dkms` if not already available: ```bash sudo apt-get install dkms ``` 2. Copy the extracted folder containing the CH341A driver files into `/usr/src/ch341a-$version`, replacing `$version` appropriately according to what was downloaded earlier. 3. Create a configuration file named after your module inside `/etc/dkms/`. An example entry could look something like below but should match exactly whatever naming convention applies here: ```ini PACKAGE_NAME="ch341a" PACKAGE_VERSION="$version" CLEAN="" BUILT_MODULE_NAME[0]="ch341a" DEST_MODULE_LOCATION[0]="/kernel/drivers/usb/serial/" AUTOINSTALL=yes ``` 4. Add the newly created package information so DKMS recognizes it: ```bash sudo dkms add ch341a/$version ``` 5. Build and install the module against currently loaded kernel versions: ```bash sudo dkms build ch341a/$version sudo dkms install ch341a/$version ``` After completing above procedures successfully, verify whether the driver has been correctly registered under the active kernel space along with checking dmesg logs for confirmation messages regarding detection of connected hardware during boot time or upon plugging/unplugging actions performed later on. --related questions-- 1. What other methods besides DKMS can be utilized for loading custom USB serial converter drivers? 2. How does one troubleshoot issues encountered while trying to load the CH341A driver? 3. Is there support provided officially by manufacturers for newer generations of similar chips beyond CH341 series? 4. Can multiple different types of USB-to-UART bridges coexist without conflicts once their respective drivers have been properly configured?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值