Submission #204461

#TimeUsernameProblemLanguageResultExecution timeMemory
20446114kg물통 (KOI17_bucket)C++11
0 / 100
6 ms380 KiB
#include <stdio.h> #include <queue> #include <map> #include <algorithm> #include <stdlib.h> #define min2(x,y) (x<y?x:y) using namespace std; map<pair<int,int>,bool> check; queue<pair<pair<int,int>,int> > Q; int A, B, MA, MB, lev; void Push(int x, int y){ if(!check[{x,y}]){ check[{x,y}]=true, Q.push({{x,y},lev+1}); if(x==MA && y==MB) printf("%d",lev+1), exit(true); } } int main(){ pair<int,int> x; scanf("%d %d %d %d",&A,&B,&MA,&MB); check[{0,0}]=true, Q.push({{0,0},0}); if(MA==0 && MB==0){ printf("0"); return 0; } while(!Q.empty()){ x=Q.front().first, lev=Q.front().second, Q.pop(); Push(0,x.second), Push(x.first,0); Push(A,x.second), Push(x.first,B); Push(x.first-min2(x.first,B-x.second),x.second+min2(x.first,B-x.second)); Push(x.first+min2(x.second,A-x.first),x.second-min2(x.second,A-x.first)); } printf("-1"); }

Compilation message (stderr)

bucket.cpp: In function 'int main()':
bucket.cpp:22: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,&MA,&MB);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...