2988 | 2023-02-07 12:16:10 | samat | Emezen Rt. | cpp11 | Wrong answer 0/100 | 1.07s | 26444 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){
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 | Wrong answer | 6ms | 7376 KiB | ||||
subtask2 | 0/16 | ||||||
2 | Wrong answer | 4ms | 7560 KiB | ||||
3 | Wrong answer | 4ms | 7600 KiB | ||||
4 | Wrong answer | 4ms | 7972 KiB | ||||
5 | Wrong answer | 4ms | 8044 KiB | ||||
6 | Wrong answer | 4ms | 8128 KiB | ||||
7 | Wrong answer | 4ms | 8420 KiB | ||||
8 | Wrong answer | 4ms | 8208 KiB | ||||
9 | Wrong answer | 4ms | 8464 KiB | ||||
10 | Wrong answer | 6ms | 8728 KiB | ||||
11 | Wrong answer | 7ms | 8736 KiB | ||||
12 | Wrong answer | 7ms | 8740 KiB | ||||
13 | Wrong answer | 7ms | 8932 KiB | ||||
14 | Wrong answer | 8ms | 8988 KiB | ||||
15 | Wrong answer | 7ms | 8988 KiB | ||||
16 | Wrong answer | 8ms | 9144 KiB | ||||
subtask3 | 0/18 | ||||||
17 | Wrong answer | 54ms | 11264 KiB | ||||
18 | Wrong answer | 112ms | 15156 KiB | ||||
19 | Wrong answer | 115ms | 14072 KiB | ||||
20 | Wrong answer | 8ms | 9832 KiB | ||||
21 | Wrong answer | 87ms | 16284 KiB | ||||
22 | Wrong answer | 127ms | 16920 KiB | ||||
23 | Wrong answer | 167ms | 22500 KiB | ||||
24 | Wrong answer | 162ms | 20004 KiB | ||||
25 | Wrong answer | 177ms | 24552 KiB | ||||
26 | Wrong answer | 174ms | 24128 KiB | ||||
subtask4 | 0/66 | ||||||
27 | Wrong answer | 8ms | 10436 KiB | ||||
28 | Wrong answer | 20ms | 11716 KiB | ||||
29 | Wrong answer | 48ms | 14264 KiB | ||||
30 | Wrong answer | 137ms | 23092 KiB | ||||
31 | Wrong answer | 178ms | 26312 KiB | ||||
32 | Wrong answer | 201ms | 26444 KiB | ||||
33 | Wrong answer | 199ms | 25880 KiB | ||||
34 | Wrong answer | 178ms | 25272 KiB | ||||
35 | Wrong answer | 119ms | 15840 KiB | ||||
36 | Wrong answer | 115ms | 15652 KiB | ||||
37 | Wrong answer | 6ms | 10324 KiB | ||||
38 | Wrong answer | 10ms | 10580 KiB | ||||
39 | Wrong answer | 20ms | 11100 KiB | ||||
40 | Wrong answer | 6ms | 10328 KiB | ||||
41 | Wrong answer | 7ms | 10348 KiB | ||||
42 | Time limit exceeded | 1.036s | 6964 KiB | ||||
43 | Time limit exceeded | 1.07s | 7096 KiB | ||||
44 | Wrong answer | 368ms | 10872 KiB | ||||
45 | Wrong answer | 41ms | 10648 KiB |