02.md は、 noshi91 さんによる発表 に始まるアルゴリズム群に対する、 Library Checker 提出 #199636 に至るまでの効率化のカジュアルなメモです。(当初は ScrapBox で公開、最終更新 : 2024-03-29)
ぜひ maspy さんによってもっと整理された投稿「 FPS 合成・逆関数の解説 (1) 逆関数と Power Projection」を参考にしてください。
| # include <Siv3D.hpp> // Siv3D v0.6.15 | |
| // #define ForWeb | |
| static inline String SampleProblemJson = UR"({"problem":{"field":{"size":4,"entities":[[6,3,4,0],[1,5,3,5],[2,7,0,6],[1,2,7,4]]}}})"; | |
| static inline String SampleSolutionJson = UR"({"ops": [{"n": 2,"x": 0,"y": 0},{"n": 3,"x": 1,"y": 1},{"n": 2,"x": 2,"y": 1},{"n": 2,"x": 2,"y": 2},{"n": 2,"x": 2,"y": 2}]})"; | |
| struct VerifyResult { | |
| bool isOk; |
| // The main purpose of this implementation is | |
| // to show rough code patterns of solutions. | |
| // I cannot guarantee the actual correctness of this code. | |
| // Error reporting is welcome. | |
| // 本ソースコードは解法の構造を示すためのものであり、 | |
| // 実際に正しく計算できることはあまり確認していません。 | |
| #include <vector> | |
| #include <algorithm> |
| #include <Siv3D.hpp> // Siv3D v0.6.14 | |
| namespace Procon35 { | |
| using BoardElement = int8; | |
| using Pattern = Grid<BoardElement>; | |
| using Board = Grid<int8>; | |
| const int32 FixedPatternsCount = 25; |
| #pragma once | |
| #include <Siv3D.hpp> // v0.6.15 | |
| namespace nachia { | |
| constexpr bool ISPRIME_DEBUG = false; | |
| struct Uint128Util { |
| # include <Siv3D.hpp> // Siv3D v0.6.15 | |
| // Circle{ p0, p1 } で、p0 と p1 を結ぶ線分を直径とする円を作成できます。 | |
| // triangle.getCircumscribedCircle() で三角形の外接円を作成できます。 | |
| struct DrawPoint { |
| #pragma once | |
| #include <vector> | |
| #include <algorithm> | |
| #include <iterator> | |
| namespace nachia { | |
| template<class Elem> | |
| struct AmortizedDeque { | |
| private: |
| from fractions import Fraction | |
| import math | |
| # 定数項のみ val 、それ以外は 0 | |
| def constant_fps(n, val) : | |
| res = [Fraction(0) for _ in range(n)] | |
| res[0] = val | |
| return res | |
| # 全部ゼロ |
02.md は、 noshi91 さんによる発表 に始まるアルゴリズム群に対する、 Library Checker 提出 #199636 に至るまでの効率化のカジュアルなメモです。(当初は ScrapBox で公開、最終更新 : 2024-03-29)
ぜひ maspy さんによってもっと整理された投稿「 FPS 合成・逆関数の解説 (1) 逆関数と Power Projection」を参考にしてください。
| // 計算内容: | |
| // 配列 long long A[n][n] が与えられる。はじめ、配列 X[n] の要素はすべて 0 である。 | |
| // v = 0..n-1 , d = 0..n-1 について、 v からの距離が d である頂点 x について、 X[x] に A[v][d] を加算する。 | |
| // 最終的な配列 X を求めよ。 | |
| //#define _GLIBCXX_DEBUG | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> |
| # https://atcoder.jp/contests/abc337/tasks/abc337_g | |
| include hld | |
| import std/strutils | |
| proc ABC337G() = | |
| var N = stdin.readLine.parseInt | |
| var tree = newGraph(N, true, N-1) | |
| for i in 0..<N-1: | |
| var uv = stdin.readLine.split.map parseInt |