2987 | 2023-02-07 12:15:20 | samat | Emezen Rt. | cpp11 | Wrong answer 0/100 | 1.1s | 26236 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 | 7ms | 7372 KiB | ||||
subtask2 | 0/16 | ||||||
2 | Wrong answer | 4ms | 7564 KiB | ||||
3 | Accepted | 4ms | 7780 KiB | ||||
4 | Wrong answer | 4ms | 7736 KiB | ||||
5 | Wrong answer | 4ms | 8084 KiB | ||||
6 | Wrong answer | 4ms | 8276 KiB | ||||
7 | Wrong answer | 4ms | 8372 KiB | ||||
8 | Wrong answer | 4ms | 8584 KiB | ||||
9 | Wrong answer | 4ms | 8796 KiB | ||||
10 | Wrong answer | 6ms | 9056 KiB | ||||
11 | Wrong answer | 7ms | 9268 KiB | ||||
12 | Wrong answer | 7ms | 9476 KiB | ||||
13 | Accepted | 7ms | 9728 KiB | ||||
14 | Wrong answer | 8ms | 9900 KiB | ||||
15 | Wrong answer | 8ms | 9896 KiB | ||||
16 | Accepted | 8ms | 9956 KiB | ||||
subtask3 | 0/18 | ||||||
17 | Accepted | 54ms | 12056 KiB | ||||
18 | Accepted | 112ms | 15660 KiB | ||||
19 | Accepted | 116ms | 14620 KiB | ||||
20 | Wrong answer | 8ms | 10588 KiB | ||||
21 | Accepted | 90ms | 17040 KiB | ||||
22 | Accepted | 129ms | 17560 KiB | ||||
23 | Accepted | 172ms | 22884 KiB | ||||
24 | Accepted | 172ms | 20552 KiB | ||||
25 | Accepted | 202ms | 24964 KiB | ||||
26 | Accepted | 211ms | 24316 KiB | ||||
subtask4 | 0/66 | ||||||
27 | Wrong answer | 8ms | 10540 KiB | ||||
28 | Wrong answer | 20ms | 11844 KiB | ||||
29 | Accepted | 48ms | 14308 KiB | ||||
30 | Accepted | 143ms | 23016 KiB | ||||
31 | Wrong answer | 180ms | 26236 KiB | ||||
32 | Wrong answer | 186ms | 26104 KiB | ||||
33 | Wrong answer | 179ms | 25584 KiB | ||||
34 | Wrong answer | 175ms | 25072 KiB | ||||
35 | Wrong answer | 119ms | 15576 KiB | ||||
36 | Wrong answer | 115ms | 15452 KiB | ||||
37 | Wrong answer | 6ms | 10120 KiB | ||||
38 | Wrong answer | 9ms | 10380 KiB | ||||
39 | Wrong answer | 19ms | 10956 KiB | ||||
40 | Wrong answer | 6ms | 10208 KiB | ||||
41 | Wrong answer | 6ms | 10380 KiB | ||||
42 | Time limit exceeded | 1.1s | 7080 KiB | ||||
43 | Time limit exceeded | 1.057s | 7028 KiB | ||||
44 | Wrong answer | 368ms | 10552 KiB | ||||
45 | Wrong answer | 41ms | 10432 KiB |