# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136939 | dnass | Ronald (COCI17_ronald) | C++14 | 77 ms | 6300 KiB |
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;
typedef long long int lld;
int n, m;
int adj[1010][1010];
void no(){
printf("NE\n");
}
void yes(){
printf("DA\n");
}
int main(){
memset(adj, 0, sizeof adj);
scanf("%d %d", &n, &m);
for(int i=0;i<m;i++){
int a, b; scanf("%d %d", &a, &b);
adj[a][b] = 1; adj[b][a] = 1;
}
vector<int> conns1, conns2;
int node = -1;
for(int i=1;i<=n;i++){
if(adj[1][i]==0) node = i;
else conns1.push_back(i);
}
if(node==-1){
no();
return 0;
}
for(int i=1;i<=n;i++){
if(adj[node][i]==1) conns2.push_back(i);
}
vector<int> intersection;
set_intersection(conns1.begin(), conns1.end(), conns2.begin(), conns2.end(), back_inserter(intersection));
if(!intersection.empty()){
no();
return 0;
}
conns1.push_back(1);
sort(conns1.begin(), conns1.end());
conns2.push_back(node);
sort(conns2.begin(), conns2.end());
for(int n1:conns1){
vector<int> connstest;
for(int i=1;i<=n;i++){
if(adj[n1][i]==1) connstest.push_back(i);
}
connstest.push_back(n1);
sort(connstest.begin(), connstest.end());
if(connstest==conns1){}
else{
no();
return 0;
}
}
for(int n2:conns2){
vector<int> connstest;
for(int i=1;i<=n;i++){
if(adj[n2][i]==1) connstest.push_back(i);
}
connstest.push_back(n2);
sort(connstest.begin(), connstest.end());
if(connstest==conns2){}
else{
no();
return 0;
}
}
yes();
return 0;
}
Compilation message (stderr)
# | 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... |