惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
TaoSecurity Blog
TaoSecurity Blog
博客园_首页
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
The Exploit Database - CXSecurity.com
量子位
Project Zero
Project Zero
A
Arctic Wolf
小众软件
小众软件
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
P
Privacy & Cybersecurity Law Blog
Security Latest
Security Latest
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
K
Kaspersky official blog
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Webroot Blog
Webroot Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
人人都是产品经理
人人都是产品经理
AI
AI
Cisco Talos Blog
Cisco Talos Blog
MyScale Blog
MyScale Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
S
Schneier on Security
P
Palo Alto Networks Blog

hayato

Chromium's DOM Deep Dive: Understanding Shadow DOM and Tree Structures - hayato Introducing the Task Scheduler in Chromium's Network Stack: A 0.3% Improvement in Loading Speed - hayato 出版のお知らせ 「普通の人が資産運用で99点をとる方法とその考え方」 - hayato Resource loading with Content Addressable Bundles - hayato 普通の人が資産運用で99点をとる方法とその考え方 - hayato Imperative Shadow DOM Distribution API - hayato Google にソフトウェアエンジニアとして入社して 10 年と 10 日がたちました - hayato Web のつくりかた: ソフトウェアエンジニアリングと雰囲気で理解する Web 標準とブラウザのつくりかた - hayato ブラウザのしくみ: データ構造とアルゴリズムと雰囲気で理解する DOM と Shadow DOM - hayato Rust が最強のプログラミング言語である証明 - hayato 六本木ではたらくソフトウェアエンジニアへのよくある質問とその答え (FAQ) (2015 - 2017) - hayato What's New in Shadow DOM v1 (by examples) - hayato Simple timer application for the pomodoro technique - hayato Google の面接試験で出る (はずがない)「海賊と金貨」問題を空気を読まないでプログラムで解いてみる - hayato hayato.io (4topcoder) - hayato SRM432 - hayato SRM405 - hayato SRM386 - hayato SRM385 - hayato SRM384 - ゲーム - hayato SRM369 - hayato SRM368 - hayato SRM366 - typo 2 連発 - hayato Python - generator で素数生成 - hayato New Launguage - 新言語追加の予定? - hayato lxml で HTML スクレーピング - hayato SRM358 - Today is a Bad Day (-50). - hayato SRM349 FizzBuzz 問題が簡単すぎるそんなあなたへ。「赤いマーブル問題」。 - hayato Suffix Array - hayato google-code-prettify を導入してみる - hayato Subset の生成 - hayato 2006 年のまとめ - SRM332 - hayato Google Code Jam 2006 - Championship Round - hayato Blogger Beta に移行 - hayato Google Code Jam 2006 - Round1 に挑戦 - Generics と AutoBoxing - hayato Google Code Jam 2006 - Qualification Round 通過 - hayato Google Code Jam 2006 - Qualification Round に挑戦 - hayato Google Code Jam 2006 - Practice1 - hayato Google Code Jam 2006 - 開催決定 - hayato Stay tuned... Global Google Code Jam 2006 - 秋に開催? - hayato SRM308 - Hard DP - hayato SRM304 - 条件付確率 - hayato JavaWorld に寄稿しました - hayato 2006 TopCoder Open Final Round - hayato IBM Rational Software Development Forum Tokyo で講演します - hayato SRM293 - ビンゴ - hayato 2006 TopCoder Open - Round1 撃墜 - hayato 2006 TopCoder Open - Odds 発表 - hayato 2006 TopCoder Open Qualification Round - hayato SRM291 - OutOfMemory - hayato デブサミ 2006 で講演します - hayato SRM287 - 気分は中学生?連立2元方程式 - hayato SRM281 - 2006 年はポイントゼロスタート - hayato SRM280 - Challenge 祭り - hayato SRM277 - 初賞金げっと - hayato マラソン・マッチ - hayato reStructuredText で blogger - hayato 2006 TopCoder Open - NSA がスポンサーに - hayato SRM276 - お買い物は楽しく DP で - hayato SRM273 - bit 演算は int で行われるのね - hayato SRM272 - Division1 - 4 度目の正直 - hayato JavaOne Tokyo で講演します - hayato SRM270 - Integer == Integer - hayato SRM268 - Division2 脱出 - hayato SRM266 - NASA, we have a problem... - hayato SRM265 - Division2 落ち... - hayato SRM262 - 初 Division1 は Typo に終わる - hayato SRM260 - TopCoder への挑戦のはじまり - hayato
SRM298 - ひとふで書き - hayato
2006-04-12 · via hayato

SRM298 に挑戦.

Division1 の問題です.

250 点問題.フィボナッチ数列に関する問題ですが,なにも考えず実装して終わりです.

500 点問題. 行列が複数個あるとします.それぞれの行と列のサイズが与えられます.たとえば,以下の 3 個の行列が与えられたとします.

A = 7 x 3, B = 3 x 7, C = 3 x 3

これら行列を全て使用して掛け算を行い,最終的にできる行列の行と列をかけたものの最大値を求めなさい.という問題です. たとえば,このケースなら

A * C * B = (7x3) * (3x3) * (3x7) = (7x7)

で,49 が最大です.全て使用した掛け算ができない場合は,-1 を返します.たとえば

A = 3 x 5, B = 5 x 2, C = 5 x 4

だと,全て使用した掛け算ができないので,-1 が答えになります.

...うーん,間違って解いてしまいました. bipertite matchig でいけると思ったのですけど,私のコードでは,

A = 1 x 2, B = 2 x 1, C = 3 x 4, D = 4 x 3

のようなケースでも,-1 を返しません..根本的に間違っていました.

これは,有向グラフを一筆書きできるかどうかって問題に落ち着くんですよね.グラフ理論的には, Euler Path というそうです.

1000 点問題. 長さが 50 以下の文字列が 3 つ与えられます.この 3 つの文字列に対して,共通するユニークな subsequence の数を求めなさい.という問題です.

subsequence とは,文字列から任意個の文字を取り除いてできる残りの文字列です.

たとえば,"call","accelerate","candle"ならば,答えは 6 です. "c", "a", "l", "al", "ca" ,"cl"が共通する subsequence です.

ちなみに,

  • "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb"
  • "abababababababababababababababababababab"
  • "aaaabbbbaaaabbbbaaaabbbbaaaabbbbaaaabbbb"

なら,答えは,1725660 です.

30 分ほど考えたんですが,できませんでした. SRM 後に書いてみました.

public class CountingCommonSubsequences {
  char[] s1;
  char[] s2;
  char[] s3;
  int N = 50;
  long[][][] memo = new long[N][N][N];
  public long countCommonSubsequences(String a, String b, String c) {
      this.s1 = a.toCharArray();
      this.s2 = b.toCharArray();
      this.s3 = c.toCharArray();
      for (int i = 0; i < N; i++) {
          for (int j = 0; j < N; j++) {
              Arrays.fill(memo[i][j], -1);
          }
      }
      return count(0, 0, 0);
  }

  long count(int n1, int n2, int n3) {
      if (n1 >= s1.length || n2 >= s2.length || n3 >= s3.length) return 0;
      if (memo[n1][n2][n3] != -1) return memo[n1][n2][n3];

      long res = 0;

      nextchar:
      for (char c = 'a'; c <= 'z'; c++) {
          for (int i = n1; i < s1.length; i++) if (s1[i] == c) {
              for (int j = n2; j < s2.length; j++) if (s2[j] == c) {
                  for (int k = n3; k < s3.length; k++) if (s3[k] == c) {
                      res += 1 + count(i+1, j+1, k+1);
                      continue nextchar;
                  }
              }
          }
      }
      return memo[n1][n2][n3] = res;
  }

結果

System Test の結果です. ( Room Statistics )

Room Statistics

今日は,だめだめでしたね.. レーティングは,1789->1775 とやや低下.