結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | g4np0n |
提出日時 | 2022-10-15 00:17:35 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 1,978 ms / 2,000 ms |
コード長 | 16,372 bytes |
コンパイル時間 | 8,869 ms |
実行使用メモリ | 168,952 KB |
スコア | 1,025,054,094,420,463 |
最終ジャッジ日時 | 2022-10-15 00:20:21 |
合計ジャッジ時間 | 115,610 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge10 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,975 ms
31,852 KB |
testcase_01 | AC | 1,975 ms
32,060 KB |
testcase_02 | AC | 1,976 ms
32,380 KB |
testcase_03 | AC | 1,976 ms
32,188 KB |
testcase_04 | AC | 1,973 ms
31,888 KB |
testcase_05 | AC | 1,975 ms
32,152 KB |
testcase_06 | AC | 1,974 ms
32,372 KB |
testcase_07 | AC | 1,973 ms
32,344 KB |
testcase_08 | AC | 1,975 ms
31,932 KB |
testcase_09 | AC | 1,975 ms
32,140 KB |
testcase_10 | AC | 1,973 ms
32,156 KB |
testcase_11 | AC | 1,974 ms
32,128 KB |
testcase_12 | AC | 1,974 ms
32,300 KB |
testcase_13 | AC | 1,975 ms
31,972 KB |
testcase_14 | AC | 1,974 ms
31,828 KB |
testcase_15 | AC | 1,976 ms
32,268 KB |
testcase_16 | AC | 1,975 ms
32,040 KB |
testcase_17 | AC | 1,975 ms
32,172 KB |
testcase_18 | AC | 1,974 ms
32,276 KB |
testcase_19 | AC | 1,978 ms
35,956 KB |
testcase_20 | AC | 1,973 ms
31,912 KB |
testcase_21 | AC | 1,976 ms
31,948 KB |
testcase_22 | AC | 1,973 ms
32,324 KB |
testcase_23 | AC | 1,974 ms
31,864 KB |
testcase_24 | AC | 1,974 ms
32,304 KB |
testcase_25 | AC | 1,972 ms
32,212 KB |
testcase_26 | AC | 1,974 ms
32,200 KB |
testcase_27 | AC | 1,974 ms
32,228 KB |
testcase_28 | AC | 1,974 ms
32,180 KB |
testcase_29 | AC | 1,974 ms
32,264 KB |
testcase_30 | AC | 1,975 ms
32,060 KB |
testcase_31 | AC | 1,974 ms
31,856 KB |
testcase_32 | AC | 1,973 ms
31,892 KB |
testcase_33 | AC | 1,973 ms
32,232 KB |
testcase_34 | AC | 1,974 ms
31,936 KB |
testcase_35 | AC | 1,975 ms
32,036 KB |
testcase_36 | AC | 1,975 ms
32,068 KB |
testcase_37 | AC | 1,974 ms
32,116 KB |
testcase_38 | AC | 1,974 ms
32,040 KB |
testcase_39 | AC | 1,973 ms
31,888 KB |
testcase_40 | AC | 1,974 ms
32,032 KB |
testcase_41 | AC | 1,976 ms
32,016 KB |
testcase_42 | AC | 1,976 ms
31,940 KB |
testcase_43 | AC | 1,974 ms
32,004 KB |
testcase_44 | AC | 1,975 ms
32,020 KB |
testcase_45 | AC | 1,975 ms
31,816 KB |
testcase_46 | AC | 1,974 ms
32,068 KB |
testcase_47 | AC | 1,973 ms
31,800 KB |
testcase_48 | AC | 1,973 ms
31,904 KB |
testcase_49 | AC | 1,975 ms
168,952 KB |
コンパイルメッセージ
Determining projects to restore... Restored /home/judge/data/code/main.csproj (in 132 ms). .NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f Copyright (C) Microsoft Corporation.All rights reserved. プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください main -> /home/judge/data/code/bin/Release/net6.0/main.dll main -> /home/judge/data/code/bin/Release/net6.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using static System.Math; partial class Program { static int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 }; static int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 }; //const long mod = 1000000007; const long mod = 998244353; static int N; static int K; int[] T; int[] U; static int max; static Stopwatch sw = new Stopwatch(); static int limit = 1930; public void Solve() { sw.Start(); (N, K) = io.GetMulti<int, int>(); T = io.GetIntArray().Append(-1).ToArray(); U = io.GetIntArray().Append(-1).ToArray(); max = Max(T.Max(), U.Max()); var best = ((1, 1, 1), (2, 1, 1)); var bestScore = Simulation(1, 1, 1, 2, 1, 1); for (int b1 = 2; ; b1++) { if (sw.ElapsedMilliseconds > limit) break; for (int m1 = 1; m1 <= b1; m1++) { if (sw.ElapsedMilliseconds > limit) break; for (int e1 = 1; e1 <= 1; e1++) { if (sw.ElapsedMilliseconds > limit) break; for (int b2 = 2; b2 <= b1; b2++) { if (sw.ElapsedMilliseconds > limit) break; for (int m2 = 1; m2 <= b2; m2++) { if (sw.ElapsedMilliseconds > limit) break; for (int e2 = 1; e2 <= 1; e2++) { if (sw.ElapsedMilliseconds > limit) break; var score = Simulation(b1, m1, e1, b2, m2, e2); if (score > bestScore) { bestScore = score; best = ((b1, m1, e1), (b2, m2, e2)); Console.Error.WriteLine($"{best} {score}"); } } } } } } } for (int i = 0; i < N / 2; i++) { Console.WriteLine($"{best.Item1.Item1} {best.Item1.Item2} {best.Item1.Item3}"); } for (int i = N / 2; i < N; i++) { Console.WriteLine($"{best.Item2.Item1} {best.Item2.Item2} {best.Item2.Item3}"); } } public int SimulationX(int B, int M, int E, int t) { int x = 0; int d = 1; int a = B; for (int i = 0; i < t; i++) { x += d; if (x == a * d) { d *= -1; a = Max(M, a - E); } } return x; } public long Simulation(int B1, int M1, int E1, int B2, int M2, int E2) { int x1 = 0; int d1 = 1; int a1 = B1; int x2 = 0; int d2 = 1; int a2 = B2; double tsum = 0; double usum = 0; int tcnt = 0; int ucnt = 0; int t = T[0]; int u = U[0]; for (int i = 0; i < max; i++) { if (i % (1 << 14) == 0) { if (sw.ElapsedMilliseconds > limit) { return -1; } } x1 += d1; x2 += d2; if (x1 == a1 * d1) { d1 *= -1; a1 = Max(M1, a1 - E1); } if (x2 == a2 * d2) { d2 *= -1; a2 = Max(M2, a2 - E2); } if (t==i) { tsum += Round(20000000d * (N / 2) * ((N + 1) / 2) * Abs(x1 - x2) / (N * (N - 1) * (B1 + B2))); tcnt++; t = T[tcnt]; } if (u==i) { usum += Round(10000000d / (Sqrt(Abs(x1 - x2) / 20d + 1))); ucnt++; u=U[ucnt]; } } var tave = (long)Round(tsum / K); var uave = (long)Round(usum / K); return tave * uave; } IO io = new IO(); static void Main() { Console.SetIn(new StreamReader(Console.OpenStandardInput(8192))); Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); var program = new Program(); //var t = new Thread(program.Solve, 134217728); //t.Start(); //t.Join(); program.Solve(); Console.Out.Flush(); Console.Read(); } } //------------------------------------------------------------------------------------------------------------------ public static class Ex { public static void yesno(this bool b) => Console.WriteLine(b ? "yes" : "no"); public static void YesNo(this bool b) => Console.WriteLine(b ? "Yes" : "No"); public static void YESNO(this bool b) => Console.WriteLine(b ? "YES" : "NO"); public static void Yes() => Console.WriteLine("Yes"); public static void YES() => Console.WriteLine("YES"); public static void No() => Console.WriteLine("No"); public static void NO() => Console.WriteLine("NO"); public static void M1() => Console.WriteLine("-1"); public static void TakahashiAoki(this bool b) => Console.WriteLine(b ? "Takahashi" : "Aoki"); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmax(ref this int a, int b) { if (a < b) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmin(ref this int a, int b) { if (a > b) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmax(ref this long a, long b) { if (a < b) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmin(ref this long a, long b) { if (a > b) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmin<T>(ref this long a, long b) { if (a > b) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T> { if (b.CompareTo(a) > 0) { a = b; return true; } else return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } else return false; } /// <summary> /// constraintを満たす最小のインデックスを返します。 /// </summary> /// <param name="constraint">T key が満たすべき制約</param> /// <returns>制約を満たす最小のインデックス(0-indexed)</returns> public static int LowerBound<T>(this IList<T> ls, Func<T, bool> constraint) { var ng = -1; var ok = ls.Count; while (ok - ng > 1) { var mid = (ok + ng) / 2; if (constraint(ls[mid])) ok = mid; else ng = mid; } return ok; } public static void Swap(this IList<int> arr, int a, int b) => (arr[a], arr[b]) = (arr[b], arr[a]); public static long[] GetCum(this IList<long> ls) { var res = new long[ls.Count + 1]; for (int i = 0; i < ls.Count; i++) res[i + 1] = res[i] + ls[i]; return res; } public static T[] GetCum<T>(this IList<T> ls, bool fromLeft, T gen, Func<T, T, T> func) { var res = new T[ls.Count + 1]; res.AsSpan().Fill(gen); if (fromLeft) { for (int i = 0; i < ls.Count; i++) res[i + 1] = func(res[i], ls[i]); } else { for (int i = ls.Count; i > 0; i--) res[i - 1] = func(res[i], ls[i - 1]); } return res; } public static T[] Repeat<T>(this T element, int N) { var res = new T[N]; res.AsSpan().Fill(element); return res; } public static T[][] Repeat<T>(this T element, int H, int W) { var res = new T[H][]; for (int i = 0; i < H; i++) { res[i] = new T[W]; res[i].AsSpan().Fill(element); } return res; } public static T[][][] Repeat<T>(this T element, int H, int W, int R) { var res = new T[H][][]; for (int i = 0; i < H; i++) { res[i] = new T[W][]; for (int j = 0; j < W; j++) { res[i][j] = new T[R]; res[i][j].AsSpan().Fill(element); } } return res; } } class IO { public string GetStr() => Console.ReadLine().Trim(); public char GetChar() => Console.ReadLine().Trim()[0]; public int GetInt() => int.Parse(Console.ReadLine().Trim()); public long GetLong() => long.Parse(Console.ReadLine().Trim()); public double GetDouble() => double.Parse(Console.ReadLine().Trim()); public decimal GetDecimal() => decimal.Parse(Console.ReadLine().Trim()); public string[] GetStrArray() => Console.ReadLine().Trim().Split(' '); public string[][] GetStrArray(int N) { var res = new string[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' '); return res; } public int[] GetIntArray() => Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); public int[][] GetIntArray(int N) { var res = new int[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); return res; } public long[] GetLongArray() => Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); public long[][] GetLongArray(int N) { var res = new long[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); return res; } public decimal[] GetDecimalArray() => Console.ReadLine().Trim().Split(' ').Select(decimal.Parse).ToArray(); public decimal[][] GetDecimalArray(int N) { var res = new decimal[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(decimal.Parse).ToArray(); return res; } public char[] GetCharArray() => Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); public double[] GetDoubleArray() => Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); public double[][] GetDoubleArray(int N) { var res = new double[N][]; for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); return res; } public char[][] GetGrid(int H) { var res = new char[H][]; for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray(); return res; } public List<int>[] GetUnweightedAdjanceyList(int V, int E, bool isDirected, bool isNode_0indexed) { var ls = new List<int>[V]; for (int i = 0; i < V; i++) ls[i] = new List<int>(); for (int i = 0; i < E; i++) { var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); if (isNode_0indexed == false) { input[0]--; input[1]--; } ls[input[0]].Add(input[1]); if (isDirected == false) ls[input[1]].Add(input[0]); } return ls; } public List<(int to, long dist)>[] GetWeightedAdjacencyList(int V, int E, bool isDirected, bool isNode_0indexed) { var ls = new List<(int to, long dist)>[V]; for (int i = 0; i < V; i++) ls[i] = new List<(int to, long dist)>(); for (int i = 0; i < E; i++) { var str = Console.ReadLine().Split(' '); var a = int.Parse(str[0]); var b = int.Parse(str[1]); var c = long.Parse(str[2]); if (isNode_0indexed == false) { a--; b--; } ls[a].Add((b, c)); if (isDirected == false) ls[b].Add((a, c)); } return ls; } [MethodImpl(MethodImplOptions.AggressiveInlining)] bool eq<T, U>() => typeof(T).Equals(typeof(U)); [MethodImpl(MethodImplOptions.AggressiveInlining)] T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); [MethodImpl(MethodImplOptions.AggressiveInlining)] T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, decimal>() ? ct<T, decimal>(decimal.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T>(out T a) => a = cv<T>(GetStr()); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T, U) GetMulti<T, U>() { var ar = Console.ReadLine().Split(' '); return (cv<T>(ar[0]), cv<U>(ar[1])); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T, U, V) GetMulti<T, U, V>() { var ar = Console.ReadLine().Split(' '); return (cv<T>(ar[0]), cv<U>(ar[1]), cv<V>(ar[2])); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T, U, V, W) GetMulti<T, U, V, W>() { var ar = Console.ReadLine().Split(' '); return (cv<T>(ar[0]), cv<U>(ar[1]), cv<V>(ar[2]), cv<W>(ar[3])); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T, U, V, W, X) GetMulti<T, U, V, W, X>() { var ar = Console.ReadLine().Split(' '); return (cv<T>(ar[0]), cv<U>(ar[1]), cv<V>(ar[2]), cv<W>(ar[3]), cv<X>(ar[4])); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T, U, V, W, X, Y) GetMulti<T, U, V, W, X, Y>() { var ar = Console.ReadLine().Split(' '); return (cv<T>(ar[0]), cv<U>(ar[1]), cv<V>(ar[2]), cv<W>(ar[3]), cv<X>(ar[4]), cv<Y>(ar[5])); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Print() => Console.WriteLine(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Print<T>(T t) => Console.WriteLine(t); [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Print<T>(string separator, IList<T> ls) => Console.WriteLine(string.Join(separator, ls)); public void Debug<T>(IList<T> ls) { Console.Error.WriteLine(); Console.Error.WriteLine("[" + string.Join(",", ls) + "]"); } public void Debug<T>(IList<IList<T>> ls) { Console.Error.WriteLine(); foreach (var l in ls) { Console.Error.WriteLine("[" + string.Join(",", l) + "]"); } Console.Error.WriteLine(); } }