# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112695 | 2019-05-21T14:09:26 Z | arnold518 | None (KOI17_bucket) | C++14 | 236 ms | 16464 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const ll MAXN = 1e6; int a, b, c, d; struct Queue { int x, y, v; }; unordered_map<ll, int> vis; queue<Queue> Q; void enque(Queue p) { if(vis.count(p.x*MAXN+p.y)) return; vis[p.x*MAXN+p.y]=p.v; Q.push(p); } 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(); int s=now.x+now.y; Queue nxt; nxt.v=now.v+1; nxt.y=min(s, b); nxt.x=s-nxt.y; enque(nxt); nxt.x=min(s, a); nxt.y=s-nxt.x; enque(nxt); nxt.x=a; nxt.y=now.y; enque(nxt); nxt.x=now.x; nxt.y=b; enque(nxt); nxt.x=0; nxt.y=now.y; enque(nxt); nxt.x=now.x; nxt.y=0; enque(nxt); } if(vis.count(c*MAXN+d)) printf("%d", vis[c*MAXN+d]); else printf("-1"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 768 KB | Output is correct |
7 | Correct | 23 ms | 3248 KB | Output is correct |
8 | Correct | 70 ms | 8256 KB | Output is correct |
9 | Correct | 71 ms | 8272 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 768 KB | Output is correct |
7 | Correct | 23 ms | 3248 KB | Output is correct |
8 | Correct | 70 ms | 8256 KB | Output is correct |
9 | Correct | 71 ms | 8272 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 256 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 768 KB | Output is correct |
7 | Correct | 23 ms | 3248 KB | Output is correct |
8 | Correct | 70 ms | 8256 KB | Output is correct |
9 | Correct | 71 ms | 8272 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 256 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 4 ms | 512 KB | Output is correct |
29 | Correct | 2 ms | 256 KB | Output is correct |
30 | Correct | 2 ms | 256 KB | Output is correct |
31 | Correct | 8 ms | 1024 KB | Output is correct |
32 | Correct | 14 ms | 1792 KB | Output is correct |
33 | Correct | 116 ms | 8348 KB | Output is correct |
34 | Correct | 9 ms | 1152 KB | Output is correct |
35 | Correct | 5 ms | 640 KB | Output is correct |
36 | Correct | 3 ms | 384 KB | Output is correct |
37 | Correct | 8 ms | 1152 KB | Output is correct |
38 | Correct | 10 ms | 1280 KB | Output is correct |
39 | Correct | 11 ms | 1280 KB | Output is correct |
40 | Correct | 5 ms | 768 KB | Output is correct |
41 | Correct | 29 ms | 3248 KB | Output is correct |
42 | Correct | 33 ms | 3592 KB | Output is correct |
43 | Correct | 17 ms | 1960 KB | Output is correct |
44 | Correct | 11 ms | 1280 KB | Output is correct |
45 | Correct | 236 ms | 16464 KB | Output is correct |
46 | Correct | 2 ms | 384 KB | Output is correct |