Submission #204461

# Submission time Handle Problem Language Result Execution time Memory
204461 2020-02-25T19:53:31 Z 14kg None (KOI17_bucket) C++11
0 / 100
6 ms 380 KB
#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

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 time Memory Grader output
1 Runtime error 5 ms 256 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 256 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Runtime error 5 ms 380 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 256 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -