Submission #132049

#TimeUsernameProblemLanguageResultExecution timeMemory
132049bogdan10bos007 (CEOI14_007)C++14
0 / 100
339 ms23544 KiB
/// 00:04 why? #include <bits/stdc++.h> using namespace std; const int NMAX = 2e5 + 5; int N, M, S, D, A, B; vector<int> edg[NMAX]; vector<int> BFS(int start) { vector<int> d(N + 1, 1 << 30); d[start] = 0; queue<int> q; q.push(start); while(!q.empty()) { int nod = q.front(); q.pop(); for(auto nxt: edg[nod]) if(d[nxt] > d[nod] + 1) { d[nxt] = d[nod] + 1; q.push(nxt); } } return d; } int main() { //freopen("1.in", "r", stdin); scanf("%d%d", &N, &M); scanf("%d%d%d%d", &S, &D, &A, &B); for(int i = 1; i <= M; i++) { int x, y; scanf("%d%d", &x, &y); edg[x].push_back(y); edg[y].push_back(x); } auto dS = BFS(S); auto dD = BFS(D); if(dD[A] + 1 <= dS[A] || dD[B] + 1 <= dS[B]) { printf("-1\n"); exit(0); } int timp = min(dD[A] - dS[A], dD[B] - dS[B]); printf("%d\n", timp); return 0; }

Compilation message (stderr)

007.cpp: In function 'int main()':
007.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
007.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &S, &D, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...