結果
問題 | No.2640 traO Stamps |
ユーザー | tobisatis |
提出日時 | 2024-02-19 21:48:20 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,483 bytes |
コンパイル時間 | 9,363 ms |
コンパイル使用メモリ | 168,768 KB |
実行使用メモリ | 238,580 KB |
最終ジャッジ日時 | 2024-09-29 01:45:17 |
合計ジャッジ時間 | 18,968 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
30,720 KB |
testcase_01 | AC | 54 ms
30,336 KB |
testcase_02 | AC | 53 ms
30,716 KB |
testcase_03 | AC | 52 ms
30,592 KB |
testcase_04 | AC | 53 ms
30,720 KB |
testcase_05 | AC | 53 ms
30,336 KB |
testcase_06 | AC | 242 ms
71,932 KB |
testcase_07 | AC | 241 ms
72,232 KB |
testcase_08 | AC | 275 ms
74,572 KB |
testcase_09 | AC | 224 ms
67,840 KB |
testcase_10 | AC | 268 ms
73,796 KB |
testcase_11 | AC | 223 ms
67,968 KB |
testcase_12 | AC | 247 ms
74,708 KB |
testcase_13 | AC | 237 ms
68,352 KB |
testcase_14 | AC | 258 ms
74,568 KB |
testcase_15 | WA | - |
testcase_16 | AC | 237 ms
73,680 KB |
testcase_17 | AC | 241 ms
73,800 KB |
testcase_18 | AC | 237 ms
69,120 KB |
testcase_19 | AC | 257 ms
74,972 KB |
testcase_20 | AC | 252 ms
74,300 KB |
testcase_21 | WA | - |
testcase_22 | AC | 269 ms
74,828 KB |
testcase_23 | AC | 248 ms
67,968 KB |
testcase_24 | AC | 251 ms
68,096 KB |
testcase_25 | AC | 273 ms
74,364 KB |
testcase_26 | AC | 245 ms
75,244 KB |
testcase_27 | AC | 237 ms
75,140 KB |
testcase_28 | AC | 229 ms
75,228 KB |
testcase_29 | AC | 245 ms
75,304 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (92 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } abstract class SegmentTree<TMonoid> { public interface IOperator { TMonoid IdentityElement { get; } TMonoid Operation(TMonoid x, TMonoid y); } public interface IBinarySearchOperator { bool F(TMonoid value); } public class Body<TOperator> where TOperator : struct, IOperator { public int BaseSize { get; init; } protected int Height { get; init; } protected TOperator Op { get; init; } protected TMonoid[] Values { get; init; } public Body(TMonoid[] initial, TOperator op = default) { Op = op; (BaseSize, Height) = (1, 0); while (BaseSize < initial.Length) (BaseSize, Height) = (BaseSize << 1, Height + 1); var size = BaseSize << 1; Values = new TMonoid[size]; for (var i = 0; i < size; i++) Values[i] = op.IdentityElement; for (var i = 0; i < initial.Length; i++) Values[i + BaseSize] = initial[i]; for (var i = BaseSize - 1; i > 0; i--) Update(i); } public TMonoid Product(int l, int r) { (l, r) = (l + BaseSize, r + BaseSize); var (resL, resR) = (Op.IdentityElement, Op.IdentityElement); while (l < r) { if ((l & 1) == 1) resL = Op.Operation(resL, Values[l++]); if ((r & 1) == 1) resR = Op.Operation(Values[--r], resR); (l, r) = (l >> 1, r >> 1); } return Op.Operation(resL, resR); } public void Set(int index, TMonoid value) { var j = index + BaseSize; Values[j] = value; for (var i = 1; i <= Height; i++) Update(j >> i); } // the result might be greater than n public int MinIndex<TMinIndexOperator>(TMinIndexOperator op = default) where TMinIndexOperator : struct, IBinarySearchOperator { if (!op.F(Values[1])) return BaseSize + 1; var product = Op.IdentityElement; var (res, w, i) = (0, BaseSize, 1); while (w > 0) { var p = Op.Operation(product, Values[i]); if (!op.F(p)) { res += w; i++; product = p; } w >>= 1; i <<= 1; } return res + 1; } protected void Update(int k) { Values[k] = Op.Operation(Values[k << 1], Values[(k << 1) + 1]); } } } struct Op : SegmentTree<long>.IOperator { public long IdentityElement => 0; public long Operation(long x, long y) => x + y; } class AtCoder { object? Solve() { var n = Int(); var m = Int(); var k = Int(); var sz = (k + 1).Repeat(() => Int() - 1); var g = new long[n, n]; var max = long.MaxValue / 8; for (var i = 0; i < n; i++) for (var j = 0; j < n; j++) if (i != j) g[i, j] = max; for (var i = 0; i < m; i++) { var a = Int() - 1; var b = Int() - 1; var c = Int(); g[a, b] = c; g[b, a] = c; } for (var i = 0; i < n; i++) for (var j = 0; j < n; j++) for (var v = 0; v < n; v++) { g[i, j] = Math.Min(g[i, j], g[i, v] + g[v, j]); } var init = new long[k]; for (var i = 0; i < k; i++) init[i] = g[sz[i], sz[i + 1]]; var tree = new SegmentTree<long>.Body<Op>(init); var q = Int(); var ans = new List<long>(); for (var i = 0; i < q; i++) { var t = Int(); var x = Int(); var y = Int(); if (t == 1) { y--; sz[x] = y; if (x > 0) tree.Set(x - 1, g[sz[x - 1], y]); if (x < k) tree.Set(x, g[y, sz[x + 1]]); } else { ans.Add(tree.Product(x, y)); } } Out(ans); return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty<string>(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; #pragma warning disable IDE0051 string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0); return input[iter++]; } T Input<T>() where T : IParsable<T> => T.Parse(String(), null); int Int() => Input<int>(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } #pragma warning restore IDE0051 }