Skip to content

Commit

Permalink
style: add clang-format configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Aug 13, 2022
1 parent 3a71796 commit 06b44c5
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 16 deletions.
137 changes: 137 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...

Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public:

bool dfs(int i) {
if (i == n) return true;
if (f[i] != -1 ) return f[i] == 1;
if (f[i] != -1) return f[i] == 1;
bool res = false;
if (i < n - 1 && nums[i] == nums[i + 1]) res = res || dfs(i + 2);
if (i < n - 2 && nums[i] == nums[i + 1] && nums[i + 1] == nums[i + 2]) res = res || dfs(i + 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public:

bool dfs(int i) {
if (i == n) return true;
if (f[i] != -1 ) return f[i] == 1;
if (f[i] != -1) return f[i] == 1;
bool res = false;
if (i < n - 1 && nums[i] == nums[i + 1]) res = res || dfs(i + 2);
if (i < n - 2 && nums[i] == nums[i + 1] && nums[i + 1] == nums[i + 2]) res = res || dfs(i + 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Solution {
vector<int> f;
vector<int> nums;
int n;

bool validPartition(vector<int>& nums) {
n = nums.size();
this->nums = nums;
Expand All @@ -13,7 +13,7 @@ class Solution {

bool dfs(int i) {
if (i == n) return true;
if (f[i] != -1 ) return f[i] == 1;
if (f[i] != -1) return f[i] == 1;
bool res = false;
if (i < n - 1 && nums[i] == nums[i + 1]) res = res || dfs(i + 2);
if (i < n - 2 && nums[i] == nums[i + 1] && nums[i + 1] == nums[i + 2]) res = res || dfs(i + 3);
Expand Down
6 changes: 2 additions & 4 deletions solution/2300-2399/2370.Longest Ideal Subsequence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ public:
vector<int> dp(n, 1);
unordered_map<char, int> d;
d[s[0]] = 0;
for (int i = 1; i < n; ++i)
{
for (int i = 1; i < n; ++i) {
char a = s[i];
for (char b = 'a'; b <= 'z'; ++b)
{
for (char b = 'a'; b <= 'z'; ++b) {
if (abs(a - b) > k) continue;
if (d.count(b)) dp[i] = max(dp[i], dp[d[b]] + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ public:
vector<int> dp(n, 1);
unordered_map<char, int> d;
d[s[0]] = 0;
for (int i = 1; i < n; ++i)
{
for (int i = 1; i < n; ++i) {
char a = s[i];
for (char b = 'a'; b <= 'z'; ++b)
{
for (char b = 'a'; b <= 'z'; ++b) {
if (abs(a - b) > k) continue;
if (d.count(b)) dp[i] = max(dp[i], dp[d[b]] + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ class Solution {
vector<int> dp(n, 1);
unordered_map<char, int> d;
d[s[0]] = 0;
for (int i = 1; i < n; ++i)
{
for (int i = 1; i < n; ++i) {
char a = s[i];
for (char b = 'a'; b <= 'z'; ++b)
{
for (char b = 'a'; b <= 'z'; ++b) {
if (abs(a - b) > k) continue;
if (d.count(b)) dp[i] = max(dp[i], dp[d[b]] + 1);
}
Expand Down

0 comments on commit 06b44c5

Please sign in to comment.