Submission #147887

#TimeUsernameProblemLanguageResultExecution timeMemory
147887arnold518물통 (KOI17_bucket)C++14
100 / 100
692 ms25344 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int A, B, C, D; struct Queue { int x, y, val; }; queue<Queue> Q; map<pii, int> vis; void enque(int x, int y, int val) { if(vis.count({x, y})) return; vis[{x, y}]=val; Q.push({x, y, val}); } int main() { int i, j; scanf("%d%d%d%d", &A, &B, &C, &D); enque(0, 0, 0); while(!Q.empty()) { Queue now=Q.front(); Q.pop(); enque(A, now.y, now.val+1); enque(now.x, B, now.val+1); enque(0, now.y, now.val+1); enque(now.x, 0, now.val+1); enque(now.x+now.y-min(now.y+now.x, B), min(now.y+now.x, B), now.val+1); enque(min(now.x+now.y, A), now.x+now.y-min(now.x+now.y, A), now.val+1); } if(vis.count({C, D})) printf("%d", vis[{C, D}]); else printf("-1"); }

Compilation message (stderr)

bucket.cpp: In function 'int main()':
bucket.cpp:26:9: warning: unused variable 'i' [-Wunused-variable]
     int i, j;
         ^
bucket.cpp:26:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
bucket.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &A, &B, &C, &D);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...