Submission #126577

#TimeUsernameProblemLanguageResultExecution timeMemory
126577_SamirRonald (COCI17_ronald)C++17
15 / 120
189 ms15540 KiB
//github.com/nya-nya-meow/CompetitiveProgramming/blob/master/CSES/CSES%201112%20-%20Substrings.cpp #include<bits/stdc++.h> #define pi 3.141592654 #define forr(i,a,b) for(int i=a;i<=b;i++) #define F first #define S second #define input ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; typedef pair<double,double>pdd; typedef long long ll; typedef pair<ll, ll>pii; typedef complex<double> point; //int x[8]={1,0,0,-1,-1,-1,1,1}; //int y[8]={0,1,-1,0,-1,1,-1,1}; const double EPS= 1e-8; const int N = 1e5+5, M = 2e5+5, OO = 0x3f3f3f3f; int n,m,vis[2005],id,ck[5000000]; vector<int>a[2005]; void dfs(int u) { vis[u]=id; for(auto v:a[u]) if(vis[v]==-1)dfs(v); } int main() { input; cin>>n>>m; int u,v; forr(i,1,m) { cin>>u>>v; a[u].push_back(v); a[v].push_back(u); } memset(vis,-1,sizeof vis); forr(i,1,n) { if(vis[i]==-1) { id++; dfs(i); } } set<pair<int,int>>c1,c2; int cnt1=0,cnt2=0; forr(i,1,n) { if(vis[i]==1) for(auto v:a[i]) cnt1++,c1.insert({min(i,v),max(i,v)}); else if(vis[i]==2) for(auto v:a[i]) cnt2++,c2.insert({min(i,v),max(i,v)}); } for(int i=1;i<=2000;i++)ck[i]=i*(i-1)/2; if((id==1&&ck[cnt1]==(int)c1.size())||(id==2&&ck[cnt1]==(int)c1.size()&&ck[cnt2]==(int)c2.size()))cout<<"DA"<<endl; else cout<<"NE"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...