Submission #129874

#TimeUsernameProblemLanguageResultExecution timeMemory
129874KOMJ01산만한 고양이 (KOI17_cat)C++14
0 / 100
2048 ms46480 KiB
#include <stdio.h> #include <iostream> #include <vector> #include <algorithm> #include <math.h> using namespace std; int b1; int cycle(int a, int b2); vector<vector<int>> v; vector<int> v2; vector<int> cnt; int main() { int n,m,a,b,t=0, i; cin >> n >> m; v.resize(n); v2.resize(n); cnt.resize(n); for(i=0;i<n;++i){ v2.at(i)=0; } for(i=0; i<m; ++i) { cin >> a >> b; v.at(a-1).push_back(b-1); v.at(b-1).push_back(a-1); } b1=0; int temp1, temp2; temp1=cycle(1,-1); for(i=0; i<n;++i) { if(cnt.at(i)==0){temp2=cycle(i,-1);break;} } if(temp1==0 && temp2==0){++t;} for(i=1;i<n;++i) { for(int j=0;j<n;++j){ v2.at(j)=0; } for(int j=0;j<n;++j){ cnt.at(j)=0; } b1=i; temp1=cycle(0,-1); for(int j=0; j<n;++j) { if(cnt.at(j)==0){temp2=cycle(j,-1);break;} } if(temp1==0 && temp2==0){t+=i+1;} } cout <<t; } int cycle(int a,int b2) { v2.at(a)=1; cnt.at(a)=1; int k; for(int i=0;i<v.at(a).size();++i){ k=v.at(a).at(i); //cout << k << " "; if(k==b1||k==b2){ //cout << k << " continue" << endl; continue; } else if(v2.at(k)==1){ //cout << "find cycle" << endl; return 1; } // cout<< v.at(a).at(i) << " ";//<< endl; if(cycle(v.at(a).at(i), a))return 1; } v2.at(a)=0; return 0; }

Compilation message (stderr)

cat.cpp: In function 'int cycle(int, int)':
cat.cpp:62:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v.at(a).size();++i){
                 ~^~~~~~~~~~~~~~~
cat.cpp: In function 'int main()':
cat.cpp:36:17: warning: 'temp2' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(temp1==0 && temp2==0){++t;}
        ~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...