Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release/atcoder
Browse files Browse the repository at this point in the history
v3.9.0-atcoder1
  • Loading branch information
kzrnm committed Jan 29, 2024
2 parents 0023ab0 + a50edce commit 1afac53
Show file tree
Hide file tree
Showing 80 changed files with 2,642 additions and 1,082 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ env:

jobs:
get-version:
uses: kzrnm/dotnet-actions/.github/workflows/get-version.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/get-version.yml@v2
with:
project-path: Directory.Build.props

format:
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v2
with:
target: ac-library-csharp.sln
dotnet-version: |
3.0.x
3.1.x
7.0.x
test:
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v2
with:
target: ac-library-csharp.sln
test-logger: GitHubActions
Expand All @@ -48,7 +48,7 @@ jobs:
publish:
needs: [get-version, test, format, build-verify]
if: ${{ needs.get-version.outputs.is-new == 'true' }}
uses: kzrnm/dotnet-actions/.github/workflows/publish.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/publish.yml@v2
with:
artifact-name: dist
version: ${{ needs.get-version.outputs.version }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/reusable_verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
build-resolve:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.0.x
3.1.x
7.0.x
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props') }}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
solution: ${{ env.WORKFLOW_BUILD_SLN }}
output-path: verify_files.json
include: Source/ac-library-csharp/** Test/ac-library-csharp.LibraryChecker/** Test/ac-library-csharp.Test
exclude: Test/ac-library-csharp.LibraryChecker/BaseSover.cs **/obj/**
exclude: Test/ac-library-csharp.LibraryChecker/BaseSolver.cs **/obj/**
unittest-result: ${{runner.temp}}/VerifierCsUnitTestResult/*.csv
problems: ${{runner.temp}}/problems-*.json
msbuild-properties: Configuration=Release
Expand All @@ -69,13 +69,13 @@ jobs:
with:
file: verify_files.json
- name: Upload binaries
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binary-${{github.sha}}
path: Test/ac-library-csharp.LibraryChecker/bin/Release

- name: Upload packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: inputs.upload-artifact
with:
name: dist
Expand All @@ -92,7 +92,7 @@ jobs:
index:
["0", "1", "2", "3", "4", "5"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up competitive-verifier
uses: competitive-verifier/actions/setup@v1
Expand All @@ -103,20 +103,20 @@ jobs:
- name: Download verify_files.json
uses: competitive-verifier/actions/download-verify-artifact@v1

- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.0.x
3.1.x
7.0.x
- name: Download binaries
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: binary-${{github.sha}}
path: Test/ac-library-csharp.LibraryChecker/bin/Release

- name: Verify
uses: competitive-verifier/actions/verify@v1
uses: competitive-verifier/actions/verify@v2
with:
destination: ${{runner.temp}}/result.json
split-size: ${{ env.SPLIT_SIZE }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ env:

jobs:
format:
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v2
with:
target: ac-library-csharp.sln
dotnet-version: 7.0.x
test:
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v2
with:
target: ac-library-csharp.sln
test-logger: GitHubActions
Expand Down
70 changes: 69 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,74 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.9.0]
### Changed
- `ILazySegtreeOperator<T, F>` implements `ISegtreeOperator<T>`

## [3.8.0] - 2023-12-03
### Added
- Create `Segtree<T>` from Span

## [3.7.0] - 2023-11-29
### Added
- Add PriorityQueue.TryPeek(out T)
- Add PriorityQueue.DequeueEnqueue(T)

## [3.6.2] - 2023-11-26
### Changed
- Fix EnqueueDequeue

## [3.6.1] - 2023-11-25
### Changed
- Fix doc of FloorSum

## [3.6.0] - 2023-11-23
### Added
- Add `Parse`/`TryParse` to `ModInt`

## [3.5.0] - 2023-10-29
### Added
- Add MfGraph.Count
### Changed
- Rename generic parameter TValue to T

## [3.4.1] - 2023-10-26
### Changed
- Rename `AtCoder.Internal.BigMul` into `AtCoder.Internal.Mul128`

## [3.4.0] - 2023-10-26
### Changed
- Separate `MathLib` and `InternalMath` implementations in separate classes

## [3.3.0] - 2023-10-25
### Added
- Add `IModInt<T>.Value` and `IModInt<T>.Mod`
### Changed
- Move `IStaticMod` to IModInterface.cs
### Removed
- Remove DebugView from expanded code

## [3.2.0] - 2023-09-25
### Added
- Add `Deque<T>.Grow(int capacity)`

### Changed
- `AtCoder.Internal.Barrett` for `2^31` < m < `2^32`
- Fix empty `Deque<T>.GetEnumerator()`

## [3.1.0] - 2023-09-24
### Added
- Add IModInt interface

## [3.0.2] - 2023-09-21
### Changed
- AtCoderAnalyzer: Create operator as readonly struct

## [3.0.1] - 2023-09-12
### Change
- Update DebugView
- Rename IMinMaxValue<T> to IMinMaxValueOperator<T>

## [3.0.0-pre8] - 2023-01-27
### Added
- Add SimpleList<T>.RemoveLastSize
Expand All @@ -19,7 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.0.0-pre5] - 2023-01-26
### Changed
- Fix LCPArray ¨ LcpArray
- Fix LCPArray LcpArray

## [3.0.0-pre4] - 2023-01-26
### Added
Expand Down
8 changes: 5 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<RepositoryUrl>https://github.com/kzrnm/ac-library-csharp</RepositoryUrl>
<PackageReleaseNotes>https://github.com/kzrnm/ac-library-csharp/blob/main/CHANGELOG.md</PackageReleaseNotes>

<Version>3.0.0-atcoder8</Version>
<AssemblyVersion>3.0.0.8</AssemblyVersion>
<Version>3.9.0-atcoder1</Version>
<AssemblyVersion>3.9.0.1</AssemblyVersion>
<RepositoryCommit Condition="'$(GIT_COMMIT)' != ''">$(GIT_COMMIT)</RepositoryCommit>

<SignAssembly>True</SignAssembly>
Expand All @@ -19,6 +19,8 @@
<EmbeddingSource>false</EmbeddingSource>
<DefineConstants Condition="'$(EmbeddingSource)'=='true'">$(DefineConstants);EMBEDDING</DefineConstants>

<SourceExpanderVersion>5.5.1</SourceExpanderVersion>

<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand All @@ -30,7 +32,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<IncludeAssets>runtime;build;native;contentfiles;analyzers;buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

Expand Down
56 changes: 32 additions & 24 deletions Source/ac-library-csharp/DataStructure/FenwickTree.GenericMath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ namespace AtCoder
/// </list>
/// <para>を O(log⁡N) で求めることが出来るデータ構造です。</para>
/// </summary>
/// <typeparam name="TValue">配列要素の型</typeparam>
/// <typeparam name="T">配列要素の型</typeparam>
[DebuggerTypeProxy(typeof(FenwickTree<>.DebugView))]
public class FenwickTree<TValue>
where TValue : IAdditionOperators<TValue, TValue, TValue>, ISubtractionOperators<TValue, TValue, TValue>, IAdditiveIdentity<TValue, TValue>
public class FenwickTree<T>
where T : IAdditionOperators<T, T, T>, ISubtractionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
[EditorBrowsable(EditorBrowsableState.Never)]
public readonly TValue[] data;
public readonly T[] data;

public int Length { get; }

Expand All @@ -39,7 +39,7 @@ public class FenwickTree<TValue>
public FenwickTree(int n)
{
Length = n;
data = new TValue[n + 1];
data = new T[n + 1];
}

/// <summary>
Expand All @@ -50,7 +50,7 @@ public FenwickTree(int n)
/// <para>計算量: O(log n)</para>
/// </remarks>
[MethodImpl(256)]
public void Add(int p, TValue x)
public void Add(int p, T x)
{
Contract.Assert((uint)p < (uint)Length, reason: $"IndexOutOfRange: 0 <= {nameof(p)} && {nameof(p)} < Length");
for (++p; p < data.Length; p += (int)InternalBit.ExtractLowestSetBit(p))
Expand All @@ -68,17 +68,17 @@ public void Add(int p, TValue x)
/// </remarks>
/// <returns>a[<paramref name="l"/>] + a[<paramref name="l"/> - 1] + ... + a[<paramref name="r"/> - 1]</returns>
[MethodImpl(256)]
public TValue Sum(int l, int r)
public T Sum(int l, int r)
{
Contract.Assert((uint)l <= (uint)r && (uint)r <= (uint)Length, reason: $"IndexOutOfRange: 0 <= {nameof(l)} && {nameof(l)} <= {nameof(r)} && {nameof(r)} <= Length");
return Sum(r) - Sum(l);
}

[MethodImpl(256)]
[EditorBrowsable(EditorBrowsableState.Never)]
public TValue Sum(int r)
public T Sum(int r)
{
TValue s = TValue.AdditiveIdentity;
T s = T.AdditiveIdentity;
for (; r > 0; r &= r - 1)
{
s += data[r];
Expand All @@ -87,40 +87,48 @@ public TValue Sum(int r)
}

[MethodImpl(256)]
public TValue Slice(int l, int len) => Sum(l, l + len);
public T Slice(int l, int len) => Sum(l, l + len);

[DebuggerDisplay("Value = {" + nameof(value) + "}, Sum = {" + nameof(sum) + "}")]
internal struct DebugItem
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
[DebuggerDisplay("Value = {" + nameof(Value) + "}, Sum = {" + nameof(Sum) + "}")]
internal readonly struct DebugItem
{
public DebugItem(TValue value, TValue sum)
public DebugItem(T value, T sum)
{
this.sum = sum;
this.value = value;
Value = value;
Sum = sum;
}
public readonly TValue value;
public readonly TValue sum;
public T Value { get; }
public T Sum { get; }
}
internal class DebugView
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly FenwickTree<TValue> fenwickTree;
public DebugView(FenwickTree<TValue> fenwickTree)
private readonly FenwickTree<T> fw;
public DebugView(FenwickTree<T> fenwickTree)
{
this.fenwickTree = fenwickTree;
fw = fenwickTree;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public DebugItem[] Items
{
get
{
var data = fenwickTree.data;
var data = fw.data;
var items = new DebugItem[data.Length - 1];
if (items.Length == 0) return System.Array.Empty<DebugItem>();

items[0] = new DebugItem(data[1], data[1]);
for (int i = 2; i < data.Length; i++)
{
int length = (int)InternalBit.ExtractLowestSetBit(i);
var pr = i - length - 1;
var sum = data[i] + (0 <= pr ? items[pr].sum : TValue.AdditiveIdentity);
var val = sum - items[i - 2].sum;
var sum = data[i] + (0 <= pr ? items[pr].Sum : T.AdditiveIdentity);
var val = sum - items[i - 2].Sum;
items[i - 1] = new DebugItem(val, sum);
}
return items;
Expand Down
Loading

0 comments on commit 1afac53

Please sign in to comment.