Submission #9594

#TimeUsernameProblemLanguageResultExecution timeMemory
9594ksmail12Your life (kriii2_Y)C++98
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdio> #include <vector> #include <queue> using namespace std; vector<bool> v; int find(vector<vector<int> > &g, queue<int> &q, int level, int n){ if(q.empty()) return 0; int curr; queue<int> next; while(!q.empty()) { curr = q.front(); q.pop(); for(vector<int>::iterator it = g[curr].begin(); it!=g[curr].end();it++) { if(*it == n && v[*it] == false) { printf("%d\n", level+1); return level; } if(!v[*it] && *it != n) { v[*it] = true; next.push(*it); } } } return find(g, next, level+1, n); } int main() { vector<vector<int> > g; queue<int> q; int n, m; scanf("%d %d", &n, &m); if(n==1) { printf("0\n"); return 0; } g.resize(n+1); v.resize(n+1); // make graph for (int i=m;i!=0;i--) { int x,y; scanf("%d %d", &x, &y); g[x].push_back(y); } // find solution q.push(1); v[1] = true; chk = g[1].size(); if(find(g, q, 0, n) == 0){ printf("-1\n"); } return 0; }

Compilation message (stderr)

Y.cpp: In function 'int main()':
Y.cpp:52:5: error: 'chk' was not declared in this scope
Y.cpp:36:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
Y.cpp:46:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]