From e3703197a9ef992f9e460574ccfe10eed2dab99b Mon Sep 17 00:00:00 2001 From: szdytom Date: Thu, 18 Jan 2024 09:40:37 +0800 Subject: [PATCH] upload files Signed-off-by: szdytom --- .clang-format | 147 ++++++++++++++++++++ .gitingore | 4 + optimizer/box-breaker.cpp | 282 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 433 insertions(+) create mode 100644 .clang-format create mode 100644 .gitingore create mode 100644 optimizer/box-breaker.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..7673774 --- /dev/null +++ b/.clang-format @@ -0,0 +1,147 @@ +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: Left +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: [] +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: All +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakStringLiterals: true +ColumnLimit: 80 +QualifierAlignment: Left +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: NextLine +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: false +FixNamespaceComments: true +ForEachMacros: [] +IfMacros: [] +IncludeBlocks: Merge +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: false +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequires: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: Wrapped +InsertBraces: false +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Left +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Cpp11 +TabWidth: 4 +UseCRLF: false +UseTab: Always + diff --git a/.gitingore b/.gitingore new file mode 100644 index 0000000..e39175e --- /dev/null +++ b/.gitingore @@ -0,0 +1,4 @@ +*.exe +*.lexe +.vscode +*.swp diff --git a/optimizer/box-breaker.cpp b/optimizer/box-breaker.cpp new file mode 100644 index 0000000..fd2eef7 --- /dev/null +++ b/optimizer/box-breaker.cpp @@ -0,0 +1,282 @@ +#include +using namespace std; + +const int n = 20; +const int q_siz = 20; +const double keep_p = 0.97; + +mt19937 mt(114514); +uniform_real_distribution<> d01(0, 1); + +struct Question { + bitset<20> M[20]; + int sx, sy, tx, ty, bx, by; +}; + +Question start_question; + +namespace Solve { +bitset<20> mp[20]; +int dis[20][20][20][20]; +queue> qu; + +inline int bfs(int px, int py, int bx, int by, int tx, int ty) { + memset(dis, 127, sizeof(dis)); + while (!qu.empty()) + qu.pop(); + + auto expand = [&](int npx, int npy, int nbx, int nby, int d) { + if (npx < 0 || npx >= n) + return; + if (npy < 0 || npy >= n) + return; + if (nbx < 0 || nbx >= n) + return; + if (nby < 0 || nby >= n) + return; + if (mp[npx][npy] == 0) + return; + if (mp[nbx][nby] == 0) + return; + if (npx == nbx && npy == nby) + return; + + if (dis[npx][npy][nbx][nby] <= d) + return; + dis[npx][npy][nbx][nby] = d; + qu.emplace(npx, npy, nbx, nby); + }; + + expand(px, py, bx, by, 0); + + while (!qu.empty()) { + auto [npx, npy, nbx, nby] = qu.front(); + int d = dis[npx][npy][nbx][nby]; + qu.pop(); + // cout<<"Now player at ( "<> s; + for (int j = 0; j < n; j++) { + if (s[j] == '#') + start_question.M[i][j] = 0; + else + start_question.M[i][j] = 1; + + if (s[j] == 'P') + start_question.sx = i, start_question.sy = j; + if (s[j] == '*') + start_question.bx = i, start_question.by = j; + if (s[j] == 'O') + start_question.tx = i, start_question.ty = j; + } + } + // cout<<"Start question : *********************"<