2986 | 2023-02-07 12:14:32 | samat | Emezen Rt. | cpp11 | Wrong answer 0/100 | 1.077s | 25588 KiB |
#include <bits/stdc++.h>
using namespace std;
int n, m, db = 0, t;
void melysegi(vector< vector<int> >& v, vector<bool>& lattam, vector<int>& jelzes, int csucs, int allapot){
if(!lattam[csucs]){
lattam[csucs] = true;
jelzes[csucs] = allapot;
for(int i = 0; i < v[csucs].size(); i++){
melysegi(v, lattam, jelzes, v[csucs][i], allapot * (-1));
}
}
else{
if(jelzes[csucs] == allapot * (-1)){
db++;
}
}
}
void beolvas(vector< vector<int> >& v){
cin >> n >> m;
for(int i = 1; i <= m; i++){
int x, y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
}
int main()
{
//ifstream cin("elod.txt");
cin >> t;
while(t){
vector< vector<int> > v(100000);
vector<bool> lattam(100000, false);
vector<int> jelzes(100000, 2);
beolvas(v);
melysegi(v, lattam, jelzes, 1, 1);
if(db > m / 2){
cout << -1 << "\n" << -1 << "\n";
}
else{
int db2 = 0;
for(int i = 1; i <= n; i++){
if(jelzes[i] == 1){
db2++;
}
}
cout << db2 << "\n";
for(int i = 1; i <= n; i++){
if(jelzes[i] == 1){
cout << i << " ";
}
}
cout << "\n";
}
db = 0;
t--;
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 6ms | 7368 KiB | ||||
subtask2 | 0/16 | ||||||
2 | Wrong answer | 4ms | 7568 KiB | ||||
3 | Accepted | 4ms | 7808 KiB | ||||
4 | Wrong answer | 4ms | 8012 KiB | ||||
5 | Wrong answer | 4ms | 8188 KiB | ||||
6 | Wrong answer | 4ms | 8332 KiB | ||||
7 | Wrong answer | 4ms | 8624 KiB | ||||
8 | Wrong answer | 4ms | 8844 KiB | ||||
9 | Wrong answer | 4ms | 8964 KiB | ||||
10 | Wrong answer | 6ms | 9036 KiB | ||||
11 | Wrong answer | 6ms | 9120 KiB | ||||
12 | Wrong answer | 7ms | 9028 KiB | ||||
13 | Accepted | 7ms | 9284 KiB | ||||
14 | Wrong answer | 7ms | 9288 KiB | ||||
15 | Wrong answer | 7ms | 9172 KiB | ||||
16 | Accepted | 8ms | 9160 KiB | ||||
subtask3 | 0/18 | ||||||
17 | Accepted | 54ms | 11264 KiB | ||||
18 | Accepted | 112ms | 14900 KiB | ||||
19 | Accepted | 118ms | 14120 KiB | ||||
20 | Wrong answer | 8ms | 9520 KiB | ||||
21 | Accepted | 94ms | 16280 KiB | ||||
22 | Accepted | 155ms | 16800 KiB | ||||
23 | Accepted | 170ms | 22164 KiB | ||||
24 | Accepted | 171ms | 19792 KiB | ||||
25 | Accepted | 207ms | 24208 KiB | ||||
26 | Accepted | 180ms | 23560 KiB | ||||
subtask4 | 0/66 | ||||||
27 | Wrong answer | 9ms | 10128 KiB | ||||
28 | Wrong answer | 23ms | 11296 KiB | ||||
29 | Accepted | 52ms | 13764 KiB | ||||
30 | Accepted | 144ms | 22344 KiB | ||||
31 | Wrong answer | 196ms | 25588 KiB | ||||
32 | Wrong answer | 180ms | 25464 KiB | ||||
33 | Wrong answer | 177ms | 24940 KiB | ||||
34 | Wrong answer | 175ms | 24420 KiB | ||||
35 | Wrong answer | 119ms | 15192 KiB | ||||
36 | Wrong answer | 115ms | 15148 KiB | ||||
37 | Wrong answer | 6ms | 9692 KiB | ||||
38 | Wrong answer | 10ms | 10200 KiB | ||||
39 | Wrong answer | 19ms | 10780 KiB | ||||
40 | Wrong answer | 4ms | 10008 KiB | ||||
41 | Wrong answer | 6ms | 10032 KiB | ||||
42 | Time limit exceeded | 1.075s | 6484 KiB | ||||
43 | Time limit exceeded | 1.077s | 6736 KiB | ||||
44 | Wrong answer | 372ms | 10264 KiB | ||||
45 | Wrong answer | 41ms | 10224 KiB |