#include <bits/stdc++.h>
using namespace std;
struct artist
{
int a,b,c,d;
};
int n,m;
int a[1005][1005];
vector<int> G[100005],Gr[100005];
vector<int> l;
bool sel[100005];
int comp[100005];
int nr = 0;
void ctc(int nod)
{
sel[nod] = true;
for(auto it : G[nod])
{
if(sel[it])
{
continue;
}
ctc(it);
}
l.push_back(nod);
}
void get_comp(int nod)
{
comp[nod] = nr;
for(auto it : Gr[nod])
{
if(comp[it])
{
continue;
}
get_comp(it);
}
}
void Add_condition_1(int x, int y)
{
G[x ^ 1].push_back(y);
Gr[y].push_back(x ^ 1);
G[y ^ 1].push_back(x);
Gr[x].push_back(y ^ 1);
}
void Add_condition_2(int x, int y)
{
G[x].push_back(y);
Gr[y].push_back(x);
G[y].push_back(x);
Gr[x].push_back(y);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("nr.in","r",stdin);
//freopen("nr.out","w",stdout);
///2 * i + 0 = nodul legit
///2 * i + 1 = nodul inversat
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
--x;
--y;
a[x][y] = 1;
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i][j]==0)
{
Add_condition_1(2 * i + 0, 2 * j + 0);
Add_condition_1(2 * i + 1, 2 * j + 1);
}
else
{
Add_condition_2(2 * i + 0, 2 * j + 0);
Add_condition_2(2 * i + 1, 2 * j + 1);
}
}
}
for(int i=0;i<2*n;i++)
{
if(!sel[i])
{
ctc(i);
}
}
reverse(l.begin(),l.end());
for(auto it : l)
{
if(!comp[it])
{
++nr;
get_comp(it);
}
}
bool ok = true;
for(int i=0;i<n;i++)
{
if(comp[2 * i + 0] == comp[2 * i + 1])
{
ok = false;
}
}
if(ok)
{
cout<<"DA"<<'\n';
}
else
{
cout<<"NE"<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
2 ms |
5076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
5072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
5204 KB |
Output is correct |
4 |
Correct |
3 ms |
5204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5460 KB |
Output is correct |
2 |
Correct |
5 ms |
5460 KB |
Output is correct |
3 |
Correct |
3 ms |
5588 KB |
Output is correct |
4 |
Correct |
3 ms |
5588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
6612 KB |
Output is correct |
2 |
Correct |
21 ms |
11092 KB |
Output is correct |
3 |
Correct |
11 ms |
8584 KB |
Output is correct |
4 |
Correct |
9 ms |
8660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
6564 KB |
Output is correct |
2 |
Correct |
21 ms |
11096 KB |
Output is correct |
3 |
Correct |
83 ms |
25164 KB |
Output is correct |
4 |
Correct |
85 ms |
25164 KB |
Output is correct |