Submission #126574

#TimeUsernameProblemLanguageResultExecution timeMemory
126574_SamirRonald (COCI17_ronald)C++17
105 / 120
197 ms26756 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; forr(i,1,n) { if(vis[i]==1) for(auto v:a[i]) c1.insert({min(i,v),max(i,v)}); else if(vis[i]==2) for(auto v:a[i]) c2.insert({min(i,v),max(i,v)}); } for(int i=1;i*(i-1)/2<=4000000;i++)ck[i*(i-1)/2]=1; if((id==1&&ck[(int)c1.size()])||(id==2&&ck[(int)c1.size()]&&ck[(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...