# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55457 | dennisstar | 물통 (KOI17_bucket) | C++11 | 19 ms | 8924 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
int Dp1[100010][2], Dp2[100010][2];
int a, b, c, d;
int l(int x, int y) {return !y?x:l(y,x%y);}
int chk()
{
if (c==0) return Dp2[d][0]?Dp2[d][0]:(1<<30);
if (c==a) return Dp2[d][1]?Dp2[d][1]:(1<<30);
if (d==0) return Dp1[c][0]?Dp1[c][0]:(1<<30);
if (d==b) return Dp1[c][1]?Dp1[c][1]:(1<<30);
}
void f(int x, int y, int lev)
{
if (chk()<=lev) return ;
if (x!=a&&y==0) Dp1[x][0]=lev;
if (x!=a&&y==b) Dp1[x][1]=lev;
if (x==0&&y!=b) Dp2[y][0]=lev;
if (x==a&&y!=b) Dp2[y][1]=lev;
if (x==c&&y==d) return ;
if (x!=a&&(!Dp2[y][1]||Dp2[y][1]>lev+1)) f(a,y,lev+1);
if (x!=0&&(!Dp2[y][0]||Dp2[y][0]>lev+1)) f(0,y,lev+1);
if (y!=b&&(!Dp1[x][1]||Dp1[x][1]>lev+1)) f(x,b,lev+1);
if (y!=0&&(!Dp1[x][0]||Dp1[x][0]>lev+1)) f(x,0,lev+1);
if (a>=x+y&&(!Dp1[x+y][0]||Dp1[x+y][0]>lev+1)) f(x+y,0,lev+1);
if (a<x+y&&(!Dp2[x+y-a][1]||Dp2[x+y-a][1]>lev+1)) f(a,x+y-a,lev+1);
if (b>=x+y&&(!Dp2[x+y][0]||Dp2[x+y][0]>lev+1)) f(0,x+y,lev+1);
if (b<x+y&&(!Dp1[x+y-b][1]||Dp1[x+y-b][1]>lev+1)) f(x+y-b,b,lev+1);
}
int main()
{
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |