This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++){
| ~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |