제출 #955449

#제출 시각아이디문제언어결과실행 시간메모리
955449hariaakas646007 (CEOI14_007)C++14
0 / 100
176 ms22976 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } int n, m; vvi graph; vi bfs(int x) { vi dist(n+1, 1e9); vb vis(n+1); queue<pii> q; q.push(mp(x, 0)); while(q.size()) { auto p = q.front(); q.pop(); if(vis[p.f]) continue; // printf("%d\n", p.f); vis[p.f] = true; dist[p.f] = p.s; for(auto e : graph[p.f]) { // printf("%d ", e); q.push(mp(e, p.s+1)); } } return dist; } int main() { // usaco(); scd(n); scd(m); int s1, s2, a, b; scd(s1); scd(s2); scd(a); scd(b); graph = vvi(n+1); frange(i, m) { int a, b; scd(a); scd(b); graph[a].pb(b); graph[b].pb(a); } vi dist1 = bfs(s1); vi dist2 = bfs(s2); // printf("%d %d %d %d\n", dist1[a], dist1[b], dist2[a], dist2[b]); if(dist1[a] > dist2[a] || dist1[b] > dist2[b]) printf("-1"); else { // if(dist2[a] == dist2[b] && dist1[a] == dist1[b]) dist1[a]++; printf("%d", min(dist2[a]-dist1[a], dist2[b]-dist1[b])); } }

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

007.cpp: In function 'void usaco()':
007.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp: In function 'int main()':
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:59:5: note: in expansion of macro 'scd'
   59 |     scd(n); scd(m);
      |     ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:59:13: note: in expansion of macro 'scd'
   59 |     scd(n); scd(m);
      |             ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:61:5: note: in expansion of macro 'scd'
   61 |     scd(s1);
      |     ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:62:5: note: in expansion of macro 'scd'
   62 |     scd(s2);
      |     ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:63:5: note: in expansion of macro 'scd'
   63 |     scd(a);
      |     ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:64:5: note: in expansion of macro 'scd'
   64 |     scd(b);
      |     ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:69:9: note: in expansion of macro 'scd'
   69 |         scd(a);
      |         ^~~
007.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
007.cpp:70:9: note: in expansion of macro 'scd'
   70 |         scd(b);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...