# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
85907 |
2018-11-22T16:42:22 Z |
tjdgus4384 |
None (KOI17_bucket) |
C++14 |
|
630 ms |
18704 KB |
#include<cstdio>
#include<queue>
#include<set>
using namespace std;
set<pair<int, int> > st;
int main()
{
int a, b, c, d;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
queue<pair<int, int> > q;
q.push({0, 0});
st.insert({0, 0});
int ans = 0;
while(!q.empty())
{
int qsize = q.size();
for(int i = 0;i < qsize;i++)
{
int f = q.front().first;
int s = q.front().second;
q.pop();
if(f == c && s == d)
{
printf("%d", ans);
return 0;
}
if(!st.count({0, s})) {q.push({0, s}); st.insert({0, s});}
if(!st.count({f, 0})) {q.push({f, 0}); st.insert({f, 0});}
if(!st.count({a, s})) {q.push({a, s}); st.insert({a, s});}
if(!st.count({f, b})) {q.push({f, b}); st.insert({f, b});}
if(f + s <= a){ if(!st.count({f + s, 0})) {q.push({f + s, 0}); st.insert({f + s, 0});}}
else if(!st.count({a, f + s - a})) {q.push({a, f + s - a}); st.insert({a, f + s - a});}
if(f + s <= b){ if(!st.count({0, f + s})) {q.push({0, f + s}); st.insert({0, f + s});}}
else if(!st.count({f + s - b, b})) {q.push({f + s - b, b}); st.insert({f + s - b, b});}
}
ans++;
}
printf("-1");
return 0;
}
Compilation message
bucket.cpp: In function 'int main()':
bucket.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &a, &b);
~~~~~^~~~~~~~~~~~~~~~~
bucket.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &c, &d);
~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
2224 KB |
Output is correct |
8 |
Correct |
2 ms |
2224 KB |
Output is correct |
9 |
Correct |
2 ms |
2224 KB |
Output is correct |
10 |
Correct |
2 ms |
2224 KB |
Output is correct |
11 |
Correct |
2 ms |
2224 KB |
Output is correct |
12 |
Correct |
2 ms |
2224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
2224 KB |
Output is correct |
8 |
Correct |
2 ms |
2224 KB |
Output is correct |
9 |
Correct |
2 ms |
2224 KB |
Output is correct |
10 |
Correct |
2 ms |
2224 KB |
Output is correct |
11 |
Correct |
2 ms |
2224 KB |
Output is correct |
12 |
Correct |
2 ms |
2224 KB |
Output is correct |
13 |
Correct |
2 ms |
2224 KB |
Output is correct |
14 |
Correct |
2 ms |
2224 KB |
Output is correct |
15 |
Correct |
2 ms |
2224 KB |
Output is correct |
16 |
Correct |
2 ms |
2224 KB |
Output is correct |
17 |
Correct |
2 ms |
2224 KB |
Output is correct |
18 |
Correct |
2 ms |
2224 KB |
Output is correct |
19 |
Correct |
2 ms |
2224 KB |
Output is correct |
20 |
Correct |
2 ms |
2224 KB |
Output is correct |
21 |
Correct |
2 ms |
2224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2224 KB |
Output is correct |
2 |
Correct |
2 ms |
2224 KB |
Output is correct |
3 |
Correct |
2 ms |
2224 KB |
Output is correct |
4 |
Correct |
2 ms |
2224 KB |
Output is correct |
5 |
Correct |
3 ms |
2224 KB |
Output is correct |
6 |
Correct |
2 ms |
2224 KB |
Output is correct |
7 |
Correct |
3 ms |
2224 KB |
Output is correct |
8 |
Correct |
4 ms |
2224 KB |
Output is correct |
9 |
Correct |
2 ms |
2224 KB |
Output is correct |
10 |
Correct |
2 ms |
2224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
2224 KB |
Output is correct |
8 |
Correct |
2 ms |
2224 KB |
Output is correct |
9 |
Correct |
2 ms |
2224 KB |
Output is correct |
10 |
Correct |
2 ms |
2224 KB |
Output is correct |
11 |
Correct |
2 ms |
2224 KB |
Output is correct |
12 |
Correct |
2 ms |
2224 KB |
Output is correct |
13 |
Correct |
2 ms |
2224 KB |
Output is correct |
14 |
Correct |
2 ms |
2224 KB |
Output is correct |
15 |
Correct |
2 ms |
2224 KB |
Output is correct |
16 |
Correct |
2 ms |
2224 KB |
Output is correct |
17 |
Correct |
2 ms |
2224 KB |
Output is correct |
18 |
Correct |
2 ms |
2224 KB |
Output is correct |
19 |
Correct |
2 ms |
2224 KB |
Output is correct |
20 |
Correct |
2 ms |
2224 KB |
Output is correct |
21 |
Correct |
2 ms |
2224 KB |
Output is correct |
22 |
Correct |
2 ms |
2224 KB |
Output is correct |
23 |
Correct |
2 ms |
2224 KB |
Output is correct |
24 |
Correct |
2 ms |
2224 KB |
Output is correct |
25 |
Correct |
3 ms |
2224 KB |
Output is correct |
26 |
Correct |
2 ms |
2224 KB |
Output is correct |
27 |
Correct |
3 ms |
2224 KB |
Output is correct |
28 |
Correct |
4 ms |
2224 KB |
Output is correct |
29 |
Correct |
2 ms |
2224 KB |
Output is correct |
30 |
Correct |
2 ms |
2224 KB |
Output is correct |
31 |
Correct |
4 ms |
2224 KB |
Output is correct |
32 |
Correct |
7 ms |
2224 KB |
Output is correct |
33 |
Correct |
188 ms |
10156 KB |
Output is correct |
34 |
Correct |
3 ms |
10156 KB |
Output is correct |
35 |
Correct |
5 ms |
10156 KB |
Output is correct |
36 |
Correct |
3 ms |
10156 KB |
Output is correct |
37 |
Correct |
7 ms |
10156 KB |
Output is correct |
38 |
Correct |
18 ms |
10156 KB |
Output is correct |
39 |
Correct |
7 ms |
10156 KB |
Output is correct |
40 |
Correct |
7 ms |
10156 KB |
Output is correct |
41 |
Correct |
21 ms |
10156 KB |
Output is correct |
42 |
Correct |
43 ms |
10156 KB |
Output is correct |
43 |
Correct |
26 ms |
10156 KB |
Output is correct |
44 |
Correct |
16 ms |
10156 KB |
Output is correct |
45 |
Correct |
630 ms |
18704 KB |
Output is correct |
46 |
Correct |
2 ms |
2224 KB |
Output is correct |