2989 | 2023-02-07 12:17:25 | samat | Emezen Rt. | cpp11 | Wrong answer 0/100 | 1.074s | 25980 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 | 7320 KiB | ||||
subtask2 | 0/16 | ||||||
2 | Wrong answer | 4ms | 7576 KiB | ||||
3 | Accepted | 4ms | 7788 KiB | ||||
4 | Accepted | 4ms | 8004 KiB | ||||
5 | Accepted | 4ms | 8300 KiB | ||||
6 | Accepted | 4ms | 8248 KiB | ||||
7 | Accepted | 4ms | 8500 KiB | ||||
8 | Accepted | 4ms | 8592 KiB | ||||
9 | Accepted | 4ms | 8888 KiB | ||||
10 | Wrong answer | 6ms | 9012 KiB | ||||
11 | Wrong answer | 6ms | 9116 KiB | ||||
12 | Wrong answer | 7ms | 9132 KiB | ||||
13 | Accepted | 7ms | 9140 KiB | ||||
14 | Wrong answer | 7ms | 9332 KiB | ||||
15 | Wrong answer | 8ms | 9548 KiB | ||||
16 | Accepted | 8ms | 9400 KiB | ||||
subtask3 | 0/18 | ||||||
17 | Accepted | 56ms | 11492 KiB | ||||
18 | Accepted | 115ms | 15132 KiB | ||||
19 | Accepted | 118ms | 14092 KiB | ||||
20 | Wrong answer | 8ms | 10060 KiB | ||||
21 | Accepted | 90ms | 16532 KiB | ||||
22 | Accepted | 142ms | 17036 KiB | ||||
23 | Accepted | 172ms | 22364 KiB | ||||
24 | Accepted | 171ms | 20208 KiB | ||||
25 | Accepted | 190ms | 24448 KiB | ||||
26 | Accepted | 184ms | 23796 KiB | ||||
subtask4 | 0/66 | ||||||
27 | Wrong answer | 9ms | 10168 KiB | ||||
28 | Wrong answer | 23ms | 11312 KiB | ||||
29 | Accepted | 50ms | 13912 KiB | ||||
30 | Accepted | 143ms | 22580 KiB | ||||
31 | Accepted | 187ms | 25936 KiB | ||||
32 | Accepted | 187ms | 25980 KiB | ||||
33 | Accepted | 185ms | 25332 KiB | ||||
34 | Accepted | 196ms | 24816 KiB | ||||
35 | Accepted | 120ms | 15324 KiB | ||||
36 | Accepted | 115ms | 15196 KiB | ||||
37 | Accepted | 4ms | 9872 KiB | ||||
38 | Accepted | 9ms | 10128 KiB | ||||
39 | Accepted | 19ms | 10644 KiB | ||||
40 | Accepted | 6ms | 9960 KiB | ||||
41 | Accepted | 6ms | 10084 KiB | ||||
42 | Time limit exceeded | 1.074s | 6748 KiB | ||||
43 | Time limit exceeded | 1.07s | 6612 KiB | ||||
44 | Wrong answer | 391ms | 10220 KiB | ||||
45 | Wrong answer | 46ms | 10104 KiB |