Submission #7338816
Source Code Expand
// luogu-judger-enable-o2#include<bits/stdc++.h> using namespace std; int flag[101]; int a,b,tot=101; inline void dfs(int n,int temp) { if(n>40||n<0||flag[n]==1) return; if(temp>tot) return; if(n==b) { if(tot>temp)tot=temp; return ; } flag[n]=1; dfs(n+1,temp+1); dfs(n-1,temp+1); dfs(n+5,temp+1); dfs(n-5,temp+1); dfs(n+10,temp+1); dfs(n-10,temp+1); flag[n]=0; } int main() { scanf("%d%d",&a,&b); dfs(a,0); printf("%d\n",tot); return 0; } #include<bits/stdc++.h> using namespace std; int cont[6]={1,5,10,-1,-5,-10},flag[1001]; int a,b,tot=1001; void dfs(int n,int temp) { if(n>40||n<0||flag[n]==1) return; if(temp>tot) return; if(n==b) { if(tot>temp)tot=temp; return ; } flag[n]=1; dfs(n+1,temp+1); dfs(n-1,temp+1); dfs(n+5,temp+1); dfs(n-5,temp+1); dfs(n+10,temp+1); dfs(n-10,temp+1); flag[n]=0; } int main() { scanf("%d%d",&a,&b); dfs(a,0); cout<<tot<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - リモコン |
User | luogu_bot2 |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 987 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:27:20: error: ‘scanf’ was not declared in this scope scanf("%d%d",&a,&b); ^ ./Main.cpp:29:19: error: ‘printf’ was not declared in this scope printf("%d\n",tot); ^ ./Main.cpp: At global scope: ./Main.cpp:34:41: error: conflicting declaration ‘int flag [1001]’ int cont[6]={1,5,10,-1,-5,-10},flag[1001]; ^ ./Main.cpp:3:5: note: previous declaration as ‘int flag [101]’ int flag[101]; ^ ./Main.cpp:35:5: error: redefinition of ‘int a’ int a,b,tot=1001; ^ ./Main.cpp:4:5: note: ‘int a’ previously declared here int a,b,tot=101; ^ ./Main.cpp:35:7: error: redefinition of ‘int b’ int a,b,tot=1001; ^ ./Main.cpp:4:7: note: ‘int b’ previously declared here int a,b,tot=101; ^ ./Main.cpp:35:9: error: redefinition of ‘int tot’ int a,b,tot=1001; ^ ./Main.cpp:4:9: note: ‘int tot’ previously defined here int a,b,tot=101; ^ ./Main.cpp: In function...