# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
98094 |
2019-02-20T16:16:28 Z |
MilkClouds |
None (KOI17_bucket) |
C++14 |
|
302 ms |
23144 KB |
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#define p make_pair
using namespace std;
map<int,bool> memo[100000];
queue< pair<int,int> > q;
int check(int a,int b){
if(memo[a][b])
return 0;
q.push(p(a,b));
memo[a][b]=true;
return 1;
}
int main(){
int a,b,c,d,idx=0,t;
cin>>a>>b>>c>>d;
// a=3;b=7;c=3;d=2;
q.push(p(0,0));
memo[0][0]=true;
while(q.size()>0){
t=q.size();
for(int i=0;i<t;i++){
pair<int,int> pp;
pp=q.front();
// cout<<idx<<" "<<pp.first<<" "<<pp.second<<endl;
if(pp.first==c and pp.second==d){
cout<<idx;
return 0;
}
q.pop();
if(pp.first!=a) check(a,pp.second);
if(pp.second!=b) check(pp.first,b);
if(pp.first!=0) check(0,pp.second);
if(pp.second!=0) check(pp.first,0);
if(pp.second+pp.first>b){
check(pp.first-b+pp.second,b);
} else {
check(0,pp.first+pp.second);
}
if(pp.second+pp.first>a){
check(a,pp.second-a+pp.first);
} else {
check(pp.first+pp.second,0);
}
}
idx++;
}
cout<<-1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
8 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
4992 KB |
Output is correct |
4 |
Correct |
7 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
8 ms |
5120 KB |
Output is correct |
7 |
Correct |
36 ms |
6904 KB |
Output is correct |
8 |
Correct |
7 ms |
5120 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
6 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
8 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
4992 KB |
Output is correct |
4 |
Correct |
7 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
8 ms |
5120 KB |
Output is correct |
7 |
Correct |
36 ms |
6904 KB |
Output is correct |
8 |
Correct |
7 ms |
5120 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
7 ms |
4992 KB |
Output is correct |
14 |
Correct |
7 ms |
4992 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
8 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
19 |
Correct |
8 ms |
4992 KB |
Output is correct |
20 |
Correct |
6 ms |
4992 KB |
Output is correct |
21 |
Correct |
6 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
4992 KB |
Output is correct |
4 |
Correct |
8 ms |
4992 KB |
Output is correct |
5 |
Correct |
8 ms |
4992 KB |
Output is correct |
6 |
Correct |
8 ms |
5120 KB |
Output is correct |
7 |
Correct |
8 ms |
5120 KB |
Output is correct |
8 |
Correct |
9 ms |
5248 KB |
Output is correct |
9 |
Correct |
8 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
8 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
4992 KB |
Output is correct |
4 |
Correct |
7 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
8 ms |
5120 KB |
Output is correct |
7 |
Correct |
36 ms |
6904 KB |
Output is correct |
8 |
Correct |
7 ms |
5120 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
7 ms |
4992 KB |
Output is correct |
14 |
Correct |
7 ms |
4992 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
8 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
19 |
Correct |
8 ms |
4992 KB |
Output is correct |
20 |
Correct |
6 ms |
4992 KB |
Output is correct |
21 |
Correct |
7 ms |
4992 KB |
Output is correct |
22 |
Correct |
7 ms |
4992 KB |
Output is correct |
23 |
Correct |
7 ms |
4992 KB |
Output is correct |
24 |
Correct |
8 ms |
4992 KB |
Output is correct |
25 |
Correct |
8 ms |
4992 KB |
Output is correct |
26 |
Correct |
8 ms |
5120 KB |
Output is correct |
27 |
Correct |
8 ms |
5120 KB |
Output is correct |
28 |
Correct |
9 ms |
5248 KB |
Output is correct |
29 |
Correct |
8 ms |
4992 KB |
Output is correct |
30 |
Correct |
7 ms |
4992 KB |
Output is correct |
31 |
Correct |
8 ms |
5248 KB |
Output is correct |
32 |
Correct |
10 ms |
5376 KB |
Output is correct |
33 |
Correct |
161 ms |
14464 KB |
Output is correct |
34 |
Correct |
9 ms |
5120 KB |
Output is correct |
35 |
Correct |
11 ms |
5248 KB |
Output is correct |
36 |
Correct |
9 ms |
5080 KB |
Output is correct |
37 |
Correct |
12 ms |
5504 KB |
Output is correct |
38 |
Correct |
20 ms |
6016 KB |
Output is correct |
39 |
Correct |
11 ms |
5376 KB |
Output is correct |
40 |
Correct |
13 ms |
5504 KB |
Output is correct |
41 |
Correct |
25 ms |
6392 KB |
Output is correct |
42 |
Correct |
44 ms |
8184 KB |
Output is correct |
43 |
Correct |
26 ms |
6776 KB |
Output is correct |
44 |
Correct |
18 ms |
6144 KB |
Output is correct |
45 |
Correct |
302 ms |
23144 KB |
Output is correct |
46 |
Correct |
6 ms |
4992 KB |
Output is correct |