제출 #136939

#제출 시각아이디문제언어결과실행 시간메모리
136939dnassRonald (COCI17_ronald)C++14
105 / 120
77 ms6300 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

ronald.cpp: In function 'int main()':
ronald.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
ronald.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~
#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...