Submission #34366

#TimeUsernameProblemLanguageResultExecution timeMemory
34366mohammad_kilaniPotemkin cycle (CEOI15_indcyc)C++14
20 / 100
1000 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define mod 1000007 #define oo 2000000000 const int N = 101; bitset< N > con[N]; int n , m; int num = 0 ; int vis[N] , vi = 0 ; void DFS(int node,vector<int> &v){ vis[node] = vi; num++; for(int i=0;i<v.size();i++){ if(vis[v[i]] != vi && con[node][v[i]]){ DFS(v[i],v); } } } void solve(vector<int> &v,int i){ if(i == n+1){ if(v.size() < 4) return; bool can = true; vi++; num = 0 ; DFS(v[0],v); if(num != v.size()) return; for(int j=0;j<v.size();j++){ int cur = 0; for(int k=0;k<v.size();k++){ if(j == k) continue; if(con[v[j]][v[k]]) cur++; } if(cur != 2) can = false; } if(can){ for(int i=0;i<v.size();i++) printf((i == 0 ? "%d" : " %d"),v[i]); puts(""); exit(0); } return ; } v.push_back(i); solve(v,i+1); v.pop_back(); solve(v,i+1); } int main() { //freopen("in.txt","r",stdin); scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int u ,v ; scanf("%d%d",&u,&v); con[u][v] = con[v][u] = true; } vector<int> ans; solve(ans,1); puts("no"); return 0; }

Compilation message (stderr)

indcyc.cpp: In function 'void DFS(int, std::vector<int>&)':
indcyc.cpp:13:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
               ^
indcyc.cpp: In function 'void solve(std::vector<int>&, int)':
indcyc.cpp:27:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(num != v.size()) return;
          ^
indcyc.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<v.size();j++){
                ^
indcyc.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=0;k<v.size();k++){
                 ^
indcyc.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0;i<v.size();i++) printf((i == 0 ? "%d" : " %d"),v[i]);
                 ^
indcyc.cpp: In function 'int main()':
indcyc.cpp:51:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
indcyc.cpp:54:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
                      ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...