#include <bits/stdc++.h>
using namespace std;
/**
struct st1d{
int sz=2;
vector<int>vls;
void init(int n){
while(sz<n) sz*=2;
vls=vector<int>(2*sz,0);
}
void update(int i,int vl,int x,int lx,int rx){
///cout<<lx<<' '<<rx<<'\n';
if(rx==lx){
vls[x]+=vl;
return;
}
int mid=(lx+rx)/2;
if(i<=mid)
update(i,vl,2*x,lx,mid);
else
update(i,vl,2*x+1,mid+1,rx);
vls[x]=vls[2*x]+vls[2*x+1];
}
void update(int i,int vl){
update(i,vl,1,0,sz-1);
}
int get(int l,int r,int x,int lx,int rx){
if(rx<l||lx>r) return 0;
if(lx>=l&&rx<=r){
return vls[x];
}
int mid=(lx+rx)/2;
return get(l,r,2*x,lx,mid)+get(l,r,2*x+1,mid+1,rx);
}
int get(int l,int r){
return get(l,r,1,0,sz-1);
}
void print(){
for(int i=1;i<=2*sz;i*=2){
for(int j=i/2;j<i;j++)
cout<<vls[j]<<' ';
cout<<'\n';
}
}
};
struct st2d{
int sz=2;
vector<st1d>vls;
void init(int n,int m){
while(sz<n) sz*=2;
st1d tmp;
tmp.init(m);
vls=vector<st1d>(2*sz,tmp);
}
void update(int ix,int iy,int vl,int x,int lx,int rx){
///cout<<lx<<' '<<rx<<'\n';
if(rx==lx){
vls[x].update(iy,vl);
return;
}
int mid=(lx+rx)/2;
if(ix<=mid)
update(ix,iy,vl,2*x,lx,mid);
else
update(ix,iy,vl,2*x+1,mid+1,rx);
vls[x].update(iy,vl);
}
void update(int ix,int iy,int vl){
update(ix,iy,vl,1,0,sz-1);
}
int get(int xl,int xr,int yl,int yr,int x,int lx,int rx){
if(rx<xl||lx>xr) return 0;
if(lx>=xl&&rx<=xr){
return vls[x].get(yl,yr);
}
int mid=(lx+rx)/2;
return get(xl,xr,yl,yr,2*x,lx,mid)+get(xl,xr,yl,yr,2*x+1,mid+1,rx);
}
int get(int xl,int xr,int yl,int yr){
return get(xl,xr,yl,yr,1,0,sz-1);
}
void print(){
for(int i=1;i<=2*sz;i*=2){
for(int j=i/2;j<i;j++)
cout<<vls[j].get(0,sz-1)<<' ';
cout<<'\n';
}
}
};
**/
vector<vector<int > >adj;
vector<int>vis;
int f=0;
void dfs(int cr,int trg=-1){
vis[cr]=1;
if(trg!=-1&&adj[cr].size()!=trg){
f=1;
return;
}
if(f)
return;
for(int i=0;i<adj[cr].size();i++){
if(!vis[adj[cr][i]])
dfs(adj[cr][i],adj[cr].size());
}
}
int main()
{
int n,e;
cin>>n>>e;
adj.resize(n);
vis=vector<int>(n,0);
for(int i=0;i<e;i++){
int x,y;
cin>>x>>y;
x--; y--;
adj[x].push_back(y);
adj[y].push_back(x);
}
for(int i=0;i<n;i++){
if(!vis[i])
dfs(i);
}
if(f)
cout<<"NE"<<'\n';
else
cout<<"DA"<<'\n';
return 0;
}
/***
1 4
100 100 100 100
*/
Compilation message
ronald.cpp: In function 'void dfs(int, int)':
ronald.cpp:112:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
112 | if(trg!=-1&&adj[cr].size()!=trg){
| ~~~~~~~~~~~~~~^~~~~
ronald.cpp:118:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
118 | for(int i=0;i<adj[cr].size();i++){
| ~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
512 KB |
Output is correct |
2 |
Correct |
52 ms |
1656 KB |
Output is correct |
3 |
Correct |
19 ms |
768 KB |
Output is correct |
4 |
Correct |
12 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
35 ms |
1272 KB |
Output is correct |
3 |
Correct |
140 ms |
3832 KB |
Output is correct |
4 |
Correct |
215 ms |
5624 KB |
Output is correct |