人话题意:给定 2n2n 个点,其中有 mm 条形如 (x,y)(x,y) 表示不能同时选 (x,y)(x,y) 的限制,问能否满足 (2i,2i1)(i[1,n])(2i,2i-1)(i\in[1,n]) 中都能选出一个点而满足限制

首先比较无脑的 2-SAT\text{2-SAT} 就是对于每个人取 i,ii,i' 然后连 (2i,2i1)(2i,2i1)(2i',2i-1)(2i,2i-1') 但是这个边处理比较毒瘤,由于 2i2i 不选对应了 2i12i-1 必须选,因此直接连最简单的 2i,2i12i,2i-1' 这种就可以了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstdlib>
#include<ctime>

typedef long long ll;

using namespace std;

namespace mstd{

inline void qread(int &x)
{
x=0; int f=1;
static char c=getchar();
while(!isdigit(c)) {if(c=='-') f=-f; c=getchar();}
while(isdigit(c)) x=(x*10+c-'0'),c=getchar();
x*=f;
}

inline void qread(long long &x)
{
x=0; long long f=1;
static char c=getchar();
while(!isdigit(c)) {if(c=='-') f=-f; c=getchar();}
while(isdigit(c)) x=(x*10+c-'0'),c=getchar();
x*=f;
}
}

const int maxn=80040;

int n,m,head[maxn],size,dfn[maxn],low[maxn],dt,bl[maxn];
int ins[maxn],cnt;

stack <int> s;

struct edge{
int next,to;
}e[maxn];

inline void addedge(int next,int to)
{
e[++size].to=to;
e[size].next=head[next];
head[next]=size;
}

void tarjan(int t)
{
dfn[t]=low[t]=++dt;
ins[t]=1;
s.push(t);
int i,j;
for(i=head[t];i;i=e[i].next)
{
j=e[i].to;
if(!dfn[j]) tarjan(j),low[t]=min(low[j],low[t]);
else if(ins[j]) low[t]=min(low[t],dfn[j]);
}
j=0;
if(dfn[t]==low[t])
{
cnt++;
while(j!=t)
{
j=s.top();
ins[j]=0;
bl[j]=cnt;
s.pop();
}
}
}

#define f(x) (x&1?(x+1):(x-1))

int main()
{
int i,j;
mstd::qread(n);
mstd::qread(m);
int t1,t2;
for(i=1;i<=m;i++) mstd::qread(t1),mstd::qread(t2),addedge(t1,f(t2)),addedge(t2,f(t1));
//for(i=1;i<=n*2;i+=2) addedge(i+1,f(i)),addedge(i,f(i+1));
for(i=1;i<=n*2;i++) if(!dfn[i]) tarjan(i);
int bj=1;
for(i=1;i<=n*2;i+=2) if(bl[i]==bl[i+1]) bj=0;
if(!bj) {printf("NIE\n");return 0;}
for(i=1;i<=n*2;i+=2) if(bl[i]<=bl[i+1]) printf("%d\n",i); else printf("%d\n",i+1);
return 0;
}