diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 7c2a072..12d4820 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 92ff32f..083d997 100644 --- a/main.cpp +++ b/main.cpp @@ -1,15 +1,36 @@ #define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" -#include using namespace olc; +std::mapblocks; +std::maptrappedBlocks; +int minX=0,maxX=0,minY=0,maxY=0,minZ=0,maxZ=0; + +bool escape(int x,int y,int z,std::mapvisited){ + visited[std::to_string(x)+"_"+std::to_string(y)+"_"+std::to_string(z)]=true; + if (x<=minX||x>=maxX||y<=minY||y>=maxY||z<=minZ||z>=maxZ){ + return true; + } else { + if (blocks.find(std::to_string(x)+"_"+std::to_string(y)+"_"+std::to_string(z))!=blocks.end()){ + return false; + } + if (visited.find(std::to_string(x+1)+"_"+std::to_string(y)+"_"+std::to_string(z))==visited.end()&&escape(x+1,y,z,visited)|| + visited.find(std::to_string(x-1)+"_"+std::to_string(y)+"_"+std::to_string(z))==visited.end()&&escape(x-1,y,z,visited)|| + visited.find(std::to_string(x)+"_"+std::to_string(y+1)+"_"+std::to_string(z))==visited.end()&&escape(x,y+1,z,visited)|| + visited.find(std::to_string(x)+"_"+std::to_string(y-1)+"_"+std::to_string(z))==visited.end()&&escape(x,y-1,z,visited)|| + visited.find(std::to_string(x)+"_"+std::to_string(y)+"_"+std::to_string(z+1))==visited.end()&&escape(x,y,z+1,visited)|| + visited.find(std::to_string(x)+"_"+std::to_string(y)+"_"+std::to_string(z-1))==visited.end()&&escape(x,y,z-1,visited)){ + return true; + } else { + return false; + } + } +} int main() { - std::mapblocks; - std::ifstream file("testinput"); - int minX=0,maxX=0,minY=0,maxY=0,minZ=0,maxZ=0; + std::ifstream file("input"); int surfaceArea=0; while (file.good()){ std::string line; @@ -25,9 +46,9 @@ int main() std::cout<