正文
增加 53 行删除 53 行
15 行未改动161718192021222324252640 行未改动67686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912016 行未改动1371381391401411421431441451461471481491501511521531541551561571581591601617 行未改动1691701711721731741751761779 行未改动18718818919019119219319419519 行未改动21521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524612 行未改动25926026126226326426526626773 行未改动3413423433443453463473483493503513523533543553563573583593603613623634 行未改动3683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134145 行未改动4204214224234244254264274284294304314324334344354364374384394404414424434444454462 行未改动44945045145245345445545645745845946046146246346446546646746846947047147247347447547647715 行未改动return ;}void main(proc_arg_list_t list){pic_layer_map[0].tmp_color = RGB(200, 200, 0);pic_layer_map[0].bfs(1, 1);pic_layer_map[1];return ;}void win_proc(proc_arg_list_t arg){40 行未改动#include <algorithm>#include <queue>#include <map>namespace winku{struct pos_t{int x, y;pos_t():x(0),y(0){}pos_t(int _x, int _y):x(_x), y(_y){}};namespace math{long long pow_2(long long d){return d * d;}}namespace mem{template<typename Tp>void alloc(Tp*& arr, int si){arr = new Tp[si];return ;}template<typename Tp, typename... Arg>void alloc(Tp*& arr, int si, Arg... ls){arr = new Tp[si];for (int i = 0; i < si; i++){alloc(arr[i], ls...);}}template<typename Tp>void free(Tp* arr){delete[] arr;return ;}template<typename Tp, typename... Arg>void free(Tp* arr, int si, Arg... ls){for (int i = 0; i < si; i++) free(arr[i], ls...);delete[] arr;return ;}}std::ofstream ferr("err.out"); using std::endl;constexpr int SIZE_OF_ST = 1024;struct win_info_t{std::string class_name;std::string caption;int win_pos_x;16 行未改动// cursor(IDC_ARROW),// icon(IDI_APPLICATION),menu_name("DefautMenuName"){}} win_info;struct winmain_arg_list_t{HINSTANCE hInst;HINSTANCE hPrev;std::string lpCmdLine;int nShowCmd;winmain_arg_list_t(){}winmain_arg_list_t(HINSTANCE _hInst,HINSTANCE _hPrev,std::string _lpCmdLine,int _nShowCmd):hInst(_hInst),hPrev(_hPrev),lpCmdLine(_lpCmdLine),nShowCmd(_nShowCmd){}};struct proc_arg_list_t{HWND hwnd;unsigned message;unsigned long long wparam;7 行未改动message(_message),wparam(_wparam),lparam(_lparam){}};struct dot_t{bool alive;COLORREF color;dot_t():alive(false), color(RGB(0, 0, 0)){}9 行未改动bool operator==(dot_t& _b){return alive == _b.alive && color == _b.color;}};struct bitmap_t{static constexpr unsigned short red = 2, green = 1, blue = 0;unsigned char* arr;unsigned short width, height, byte_len;19 行未改动at(x, y, blue) = GetBValue(color);return ;}};namespace _bfs_help{static constexpr int rdx[4] = {1, -1, 0, 0};static constexpr int rdy[4] = {0, 0, 1,-1};}struct pic_layer_t{dot_t** arr;int maxx, maxy;COLORREF tmp_color;void res(){mem::alloc(arr, win_info.win_width, win_info.win_height);maxx = win_info.win_width; maxy = win_info.win_height;return ;}pic_layer_t(int _hahaha):arr(nullptr), maxx(-1), maxy(-1), tmp_color(RGB(225, 0, 0)){}pic_layer_t():arr(nullptr), maxx(-1), maxy(-1), tmp_color(RGB(225, 0, 0)){res();}~pic_layer_t(){if(arr != nullptr){mem::free(arr, win_info.win_width);}}bool is_ok(int x, int y){return 0 <= x && x < maxx && 0 <= y && y < maxy;12 行未改动std::fill(arr[x], arr[x] + maxy, dot_t());}return ;}void bfs(int x, int y, bool is_clear = false){using namespace _bfs_help;static bool** vis = nullptr;if (vis == nullptr){73 行未改动}return ;}};bitmap_t main_bit_map;BITMAPINFO main_bit_map_info;void set_win(winmain_arg_list_t);void win_proc(proc_arg_list_t);void main(proc_arg_list_t);namespace _hdc_space{HDC hdc, hmap_dc;HBITMAP hmap;}void _begin_work(proc_arg_list_t arg){using namespace _hdc_space;main_bit_map.res();main_bit_map_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);4 行未改动main_bit_map_info.bmiHeader.biCompression = BI_RGB;main_bit_map_info.bmiHeader.biSizeImage = 0;main_bit_map_info.bmiHeader.biClrUsed = 0;main_bit_map_info.bmiHeader.biClrImportant = 0;//填写位图头hdc = GetDC(arg.hwnd);hmap_dc = CreateCompatibleDC(nullptr);hmap = CreateCompatibleBitmap(hdc, win_info.win_width, win_info.win_height);SelectObject(hmap_dc, hmap);return ;}std::map<int, pic_layer_t> pic_layer_map;bool need_update = false;void _update_window(proc_arg_list_t list){using namespace _hdc_space;main_bit_map.clear();for (auto& tmp_map : pic_layer_map){tmp_map.second.draw_to(main_bit_map);}SetDIBits(hmap_dc, hmap, 0, win_info.win_height, main_bit_map.arr,&main_bit_map_info, DIB_RGB_COLORS);BitBlt(hdc, 0, 0,win_info.win_width, win_info.win_height,hmap_dc, 0, 0, SRCCOPY);return ;}void _end_work(proc_arg_list_t list){using namespace _hdc_space;ReleaseDC(list.hwnd, hdc);exit(0);return ;}long long _window_proc(HWND hwnd, unsigned message, unsigned long long wparam, long long lparam){static bool is_begin = true;auto list = proc_arg_list_t(hwnd, message, wparam, lparam);need_update = false;5 行未改动switch(message){case WM_QUIT:case WM_CLOSE:case WM_DESTROY:_end_work(list);break;default:break;}win_proc(list);_update_window(list);return DefWindowProc(hwnd, message, wparam, lparam);}}int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrev, char* lpCmdLine, int nShowCmd){using namespace winku;set_win(winmain_arg_list_t(hInst, hPrev, lpCmdLine, nShowCmd));WNDCLASSA wc;memset(&wc, 0, sizeof(wc));wc.hbrBackground = (HBRUSH)GetStockObject(win_info.background);//-mwindowswc.hCursor = LoadCursor(nullptr, IDC_ARROW);wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);2 行未改动wc.lpfnWndProc = _window_proc;wc.lpszMenuName = win_info.menu_name.c_str();wc.style = win_info.style;RegisterClassA(&wc);HWND hwnd =CreateWindowA(win_info.class_name.c_str(),win_info.caption.c_str(),WS_VISIBLE | WS_OVERLAPPEDWINDOW,win_info.win_pos_x, win_info.win_pos_y,win_info.win_width, win_info.win_height,nullptr, nullptr, hInst, nullptr);ShowWindow(hwnd, SW_SHOWNORMAL);UpdateWindow(hwnd);MSG message;while(true){if (GetMessage(&message, nullptr, 0, 0)){TranslateMessage(&message);DispatchMessageA(&message);}}return 0;}#endif```15 行未改动161718192021222324252640 行未改动67686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912016 行未改动1371381391401411421431441451461471481491501511521531541551561571581591601617 行未改动1691701711721731741751761779 行未改动18718818919019119219319419519 行未改动21521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524612 行未改动25926026126226326426526626773 行未改动3413423433443453463473483493503513523533543553563573583593603613623634 行未改动3683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134145 行未改动4204214224234244254264274284294304314324334344354364374384394404414424434444454462 行未改动44945045145245345445545645745845946046146246346446546646746846947047147247347447547647715 行未改动return ;}void main(proc_arg_list_t list){pic_layer_map[0].tmp_color = RGB(200, 200, 0);pic_layer_map[0].bfs(1, 1);pic_layer_map[1];return ;}void win_proc(proc_arg_list_t arg){40 行未改动#include <algorithm>#include <queue>#include <map>namespace winku{struct pos_t{int x, y;pos_t():x(0),y(0){}pos_t(int _x, int _y):x(_x), y(_y){}};namespace math{long long pow_2(long long d){return d * d;}}namespace mem{template<typename Tp>void alloc(Tp*& arr, int si){arr = new Tp[si];return ;}template<typename Tp, typename... Arg>void alloc(Tp*& arr, int si, Arg... ls){arr = new Tp[si];for (int i = 0; i < si; i++){alloc(arr[i], ls...);}}template<typename Tp>void free(Tp* arr){delete[] arr;return ;}template<typename Tp, typename... Arg>void free(Tp* arr, int si, Arg... ls){for (int i = 0; i < si; i++) free(arr[i], ls...);delete[] arr;return ;}}std::ofstream ferr("err.out"); using std::endl;constexpr int SIZE_OF_ST = 1024;struct win_info_t{std::string class_name;std::string caption;int win_pos_x;16 行未改动// cursor(IDC_ARROW),// icon(IDI_APPLICATION),menu_name("DefautMenuName"){}} win_info;struct winmain_arg_list_t{HINSTANCE hInst;HINSTANCE hPrev;std::string lpCmdLine;int nShowCmd;winmain_arg_list_t(){}winmain_arg_list_t(HINSTANCE _hInst,HINSTANCE _hPrev,std::string _lpCmdLine,int _nShowCmd):hInst(_hInst),hPrev(_hPrev),lpCmdLine(_lpCmdLine),nShowCmd(_nShowCmd){}};struct proc_arg_list_t{HWND hwnd;unsigned message;unsigned long long wparam;7 行未改动message(_message),wparam(_wparam),lparam(_lparam){}};struct dot_t{bool alive;COLORREF color;dot_t():alive(false), color(RGB(0, 0, 0)){}9 行未改动bool operator==(dot_t& _b){return alive == _b.alive && color == _b.color;}};struct bitmap_t{static constexpr unsigned short red = 2, green = 1, blue = 0;unsigned char* arr;unsigned short width, height, byte_len;19 行未改动at(x, y, blue) = GetBValue(color);return ;}};namespace _bfs_help{static constexpr int rdx[4] = {1, -1, 0, 0};static constexpr int rdy[4] = {0, 0, 1,-1};}struct pic_layer_t{dot_t** arr;int maxx, maxy;COLORREF tmp_color;void res(){mem::alloc(arr, win_info.win_width, win_info.win_height);maxx = win_info.win_width; maxy = win_info.win_height;return ;}pic_layer_t(int _hahaha):arr(nullptr), maxx(-1), maxy(-1), tmp_color(RGB(225, 0, 0)){}pic_layer_t():arr(nullptr), maxx(-1), maxy(-1), tmp_color(RGB(225, 0, 0)){res();}~pic_layer_t(){if(arr != nullptr){mem::free(arr, win_info.win_width);}}bool is_ok(int x, int y){return 0 <= x && x < maxx && 0 <= y && y < maxy;12 行未改动std::fill(arr[x], arr[x] + maxy, dot_t());}return ;}void bfs(int x, int y, bool is_clear = false){using namespace _bfs_help;static bool** vis = nullptr;if (vis == nullptr){73 行未改动}return ;}};bitmap_t main_bit_map;BITMAPINFO main_bit_map_info;void set_win(winmain_arg_list_t);void win_proc(proc_arg_list_t);void main(proc_arg_list_t);namespace _hdc_space{HDC hdc, hmap_dc;HBITMAP hmap;}void _begin_work(proc_arg_list_t arg){using namespace _hdc_space;main_bit_map.res();main_bit_map_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);4 行未改动main_bit_map_info.bmiHeader.biCompression = BI_RGB;main_bit_map_info.bmiHeader.biSizeImage = 0;main_bit_map_info.bmiHeader.biClrUsed = 0;main_bit_map_info.bmiHeader.biClrImportant = 0;//填写位图头hdc = GetDC(arg.hwnd);hmap_dc = CreateCompatibleDC(nullptr);hmap = CreateCompatibleBitmap(hdc, win_info.win_width, win_info.win_height);SelectObject(hmap_dc, hmap);return ;}std::map<int, pic_layer_t> pic_layer_map;bool need_update = false;void _update_window(proc_arg_list_t list){using namespace _hdc_space;main_bit_map.clear();for (auto& tmp_map : pic_layer_map){tmp_map.second.draw_to(main_bit_map);}SetDIBits(hmap_dc, hmap, 0, win_info.win_height, main_bit_map.arr,&main_bit_map_info, DIB_RGB_COLORS);BitBlt(hdc, 0, 0,win_info.win_width, win_info.win_height,hmap_dc, 0, 0, SRCCOPY);return ;}void _end_work(proc_arg_list_t list){using namespace _hdc_space;ReleaseDC(list.hwnd, hdc);exit(0);return ;}long long _window_proc(HWND hwnd, unsigned message, unsigned long long wparam, long long lparam){static bool is_begin = true;auto list = proc_arg_list_t(hwnd, message, wparam, lparam);need_update = false;5 行未改动switch(message){case WM_QUIT:case WM_CLOSE:case WM_DESTROY:_end_work(list);break;default:break;}win_proc(list);_update_window(list);return DefWindowProc(hwnd, message, wparam, lparam);}}int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrev, char* lpCmdLine, int nShowCmd){using namespace winku;set_win(winmain_arg_list_t(hInst, hPrev, lpCmdLine, nShowCmd));WNDCLASSA wc;memset(&wc, 0, sizeof(wc));wc.hbrBackground = (HBRUSH)GetStockObject(win_info.background);//-mwindowswc.hCursor = LoadCursor(nullptr, IDC_ARROW);wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);2 行未改动wc.lpfnWndProc = _window_proc;wc.lpszMenuName = win_info.menu_name.c_str();wc.style = win_info.style;RegisterClassA(&wc);HWND hwnd =CreateWindowA(win_info.class_name.c_str(),win_info.caption.c_str(),WS_VISIBLE | WS_OVERLAPPEDWINDOW,win_info.win_pos_x, win_info.win_pos_y,win_info.win_width, win_info.win_height,nullptr, nullptr, hInst, nullptr);ShowWindow(hwnd, SW_SHOWNORMAL);UpdateWindow(hwnd);MSG message;while(true){if (GetMessage(&message, nullptr, 0, 0)){TranslateMessage(&message);DispatchMessageA(&message);}}return 0;}#endif```