Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

なんらかの出力ハッシュの方法を決める? #149

Open
yosupo06 opened this issue Oct 16, 2019 · 5 comments
Open

なんらかの出力ハッシュの方法を決める? #149

yosupo06 opened this issue Oct 16, 2019 · 5 comments
Labels
need discussion なんらかの議論

Comments

@yosupo06
Copy link
Owner

実際に出力するには非現実的な量の出力をしたい問題というのがある(素数篩、Aho-Corasickで出力位置全出力など)

こういうのに素直に対処するには、それをサブルーチンとして含めるような問題(例えば、素数の総和を出力など)を用意するというのがある

ただ、出力をなんらかの手段でハッシュ化してしまうというのも手かもしれない。その場合は問題としてあんまり簡潔じゃなくなってしまうが

@yosupo06 yosupo06 added the need discussion なんらかの議論 label Oct 16, 2019
@yosupo06 yosupo06 changed the title なんらかのハッシュの方法を決める? なんらかの出力ハッシュの方法を決める? Oct 17, 2019
@tozangezan
Copy link

xorとかじゃダメなんですか

@yosupo06
Copy link
Owner Author

yosupo06 commented May 6, 2020

同じものを2個出力するときに消えるとかが難点

@yosupo06
Copy link
Owner Author

yosupo06 commented May 6, 2020

三角形列挙で考えたこと

要件

  • 計算量が重くない: 少なくともO(M sqrt M)回計算できないといけない
  • 可換性がある: トライアングルの出力順を気にする必要がない
  • 全要素が影響する: ちょっと間違えたら死ぬというのが好ましい
  • 他の問題に使える: 問題ごとにハッシュの方法が違ったら使いにくい
  • (Optional: 不正対策): ハッシュの性質を生かした変な解法が出来ない

これを踏まえるとhash(triangle)を列挙して何らかの可換性がある操作でまとめるのが良さそう

  • hash(triangle) ^ hash(triangle) ^ ... ^ hash(triangle)
  • (hash(triangle) + hash(triangle) + ... + hash(triangle)) % 998244353
  • (hash(triangle) * hash(triangle) * ... * hash(triangle)) % 998244353

など、1つめは64bitにするとjavaが困るらしいので注意、3つめはhash(triangle)が0にならないように

@yosupo06
Copy link
Owner Author

yosupo06 commented May 6, 2020

xorは[x, x]が全部同一視、+は[x, -x]が全部同一視されることを考えると*が一番いい気がするなぁ

@yosupo06
Copy link
Owner Author

yosupo06 commented May 6, 2020

bit演算系(xorとか)とmod系の操作を混ぜればどうしようもなくなるという話があったな

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need discussion なんらかの議論
Projects
None yet
Development

No branches or pull requests

2 participants