Submission #145563

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1455632019-08-20 11:59:18surface03물통 (KOI17_bucket)C++14
100 / 100
17 ms5168 KiB
#include<stdio.h>
const int LM=(int)1e5+5;
bool used[4][LM];
int a,b,c,d;
struct State{
int L,R,S;
}que[LM*4];
int fr,re;
int push(int L,int R,int S){
int i,j;
if(L>=a)R+=L-a,L=a,i=1,j=R;
else if(R>=b)L+=R-b,R=b,i=3,j=L;
else if(L==0)i=0,j=R;
else if(R==0)i=2,j=L;
if(used[i][j])return 0;
if(L==c&&R==d)return 1;
used[i][j]=1;
que[re++]={L,R,S};
return 0;
}
int bfs(){
push(0,0,0);
if(c==0&&d==0)return 0;
while(fr<re){
State&t=que[fr++];
if(push(0,t.R,t.S+1))return t.S+1;
if(push(0,t.L+t.R,t.S+1))return t.S+1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

bucket.cpp: In function 'int main()':
bucket.cpp:39: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,&c,&d);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bucket.cpp: In function 'int push(int, int, int)':
bucket.cpp:17:17: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(used[i][j])return 0;
        ~~~~~~~~~^
bucket.cpp:17:17: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...