Submission #9519

#TimeUsernameProblemLanguageResultExecution timeMemory
9519eternalklausYour life (kriii2_Y)C++98
0 / 4
0 ms1752 KiB
/* * y.cpp * * Created on: 2014. 9. 28. * Author: minque */ #include <iostream> using namespace std; int d[100+1][100+1]; int ds[100+1][100+1]; int dream(int curr){ if(curr == 1) return 0; int n = -1; int v = 0; for(int i = 1; i <= curr; i++){ if(d[curr][i] && ds[curr][i]){ v=dream(i); if(v == -1) ds[curr][i] = 0; if(n == -1 || v < n) n = v; } } return (n < 0 ? n : n+1); } int main(){ int n, m; cin>>n>>m; for(int i = 0; i < n; i++){ int x, y; cin>>x>>y; d[x][y] = d[y][x] = 1; ds[x][y] = ds[y][x] = 1; } int v = dream(m); cout<<v<<endl; return 0; } /* 4 4 1 2 2 3 3 4 2 4 6 5 1 2 1 3 2 3 2 4 4 5 2 5 3 5 1 2 3 4 4 5 * */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...