제출 #172941

#제출 시각아이디문제언어결과실행 시간메모리
172941phillipPotemkin cycle (CEOI15_indcyc)C++14
50 / 100
1094 ms115696 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; int vis[1009][1009],dep[1009]; vector<int>v[1009][1009],vv[1009]; vector<pair<int,int> >p; int cn[1009][1009]; int n,m,d; vector<int>c; void checkmn(int x,int par) { int mxd=0; for(int i=0;i<v[par][x].size();i++) { mxd=max(mxd,dep[v[par][x][i]]); } for(int i=mxd;i<c.size()-1;i++) { if(cn[c[i]][c[i+1]]==0) { return; } } for(int i=mxd;i<c.size();i++) { cout<<c[i]+1<<" "; } exit(0); } void dfs(int x,int par) { //cout<<x<<" "<<par<<"\n"; dep[x]=d; d++; vis[par][x]=1; c.push_back(x); for(int i=0;i<v[par][x].size();i++) { int y=v[par][x][i]; //if(vis[x][y])continue; if(dep[y]!=-1) { checkmn(x,par); } else dfs(y,x); } dep[x]=-1; d--; c.pop_back(); } int main() { memset(dep,-1,sizeof(dep)); cin>>n>>m; int x,y; for(int i=0;i<m;i++) { cin>>x>>y; x--;y--; p.push_back({x,y}); cn[x][y]=1; cn[y][x]=1; vv[x].push_back(y); vv[y].push_back(x); } for(int i=0;i<m;i++) { x=p[i].first; y=p[i].second; //cout<<x<<" "<<y<<": "; for(int j=0;j<vv[y].size();j++) { if(vv[y][j]==x)continue; if(cn[vv[y][j]][x])continue; v[x][y].push_back(vv[y][j]); // cout<<v[x][y].back()<<" "; } swap(x,y); //cout<<"\n"; //cout<<x<<" "<<y<<": "; for(int j=0;j<vv[y].size();j++) { if(vv[y][j]==x)continue; if(cn[vv[y][j]][x])continue; v[x][y].push_back(vv[y][j]); // cout<<v[x][y].back()<<" "; } // cout<<"\n"; } d=1; for(int i=0;i<m;i++) { x=p[i].first; y=p[i].second; c.clear(); if(vis[x][y]==0) { dep[x]=0; c.push_back(x); dfs(y,x); c.pop_back(); dep[x]=-1; } swap(x,y); c.clear(); //if(vis[x][y]==0) //{ dep[x]=0; c.push_back(x); dfs(y,x); c.pop_back(); dep[x]=-1; //} } cout<<"no"; }

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

indcyc.cpp: In function 'void checkmn(int, int)':
indcyc.cpp:13:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[par][x].size();i++)
                 ~^~~~~~~~~~~~~~~~~
indcyc.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=mxd;i<c.size()-1;i++)
                   ~^~~~~~~~~~~
indcyc.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=mxd;i<c.size();i++)
                   ~^~~~~~~~~
indcyc.cpp: In function 'void dfs(int, int)':
indcyc.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[par][x].size();i++)
                 ~^~~~~~~~~~~~~~~~~
indcyc.cpp: In function 'int main()':
indcyc.cpp:71:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<vv[y].size();j++)
                     ~^~~~~~~~~~~~~
indcyc.cpp:81:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<vv[y].size();j++)
                     ~^~~~~~~~~~~~~
#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...