Giter Club home page Giter Club logo

library's People

Contributors

ajayreddy17 avatar kagemeka avatar maspypy avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

library's Issues

find_cycle_undirected について

// {vs, es}、存在しなければ empty
// 極小なものを返す
template <typename GT>
pair<vc<int>, vc<int>> find_cycle_undirected(GT& G) {

検証してみたら、「極小なものを返す」はできません。( 実際、O(n)では厳しいと思います )

n=7 m=7 edges= [[1,3],[3,5],[5,1],[0,2],[2,4],[4,6],[6,0]] 

7 7
7 7
1 3
3 5
5 1
0 2 
2 4
4 6
6 0
=>
出力:0、6、4、2 からなるサイクル

極小なものじゃないです。正解は 1、3、5 です。

もし何か問題があれば,教えて頂けると助かります。

バグを発見しました~

https://maspypy.github.io/library/string/longest_common_substring.hpp

#include "string/suffix_array.hpp"

template <typename STRING>
tuple<int, int, int, int> longest_common_substring(STRING& S, STRING& T) {
  int dummy = max<int>(*max_element(all(S)), *max_element(all(T))) + 1;
  STRING ST;
  for (auto&& x: S) ST.push_back(x);
  ST.push_back(dummy);
  for (auto&& x: T) ST.push_back(x);
  Suffix_Array X(ST);
  auto& SA = X.SA;
  auto& LCP = X.LCP;

  tuple<int, int, int, int> res = {0, 0, 0, 0};
  int n = 0;
  FOR(i, len(ST) - 1) {
    if ((SA[i] < len(S)) != (SA[i + 1] < len(S))) {
      if (chmax(n, LCP[i])) {

        //  ここで、SA[i] は s の 部分文字列でない可能性があります。(swap必要)
        //
        int a = SA[i];
        int b = SA[i + 1] - len(S) - 1;
        res = {a, a + n, b, b + n};
      }
    }
  }
  return res;
}

少し調整しました (cppは苦手で擬似コード)

// swap追加
i1, i2 := sa[i], sa[i+1]
if i1 > i2 {
  i1, i2 = i2, i1
}
a := i1;
b := i2 - len(s) - 1;

FASTIO

These codes are not suitable for other implementations of FASTIO.

https://github.com/maspypy/library/blob/6c4cd5a3d8c3219692f1b7cc98a5cac630c7fb24/mod/modint.hpp#L81C14-L81C14

#ifdef FASTIO
template <int mod>
void rd(modint<mod> &x) {
  fastio::rd(x.val);
  assert(0 <= x.val && x.val < mod);
}
template <int mod>
void wt(modint<mod> x) {
  fastio::wt(x.val);
}
#endif

There are many places that have this problem.This is an example.

To the people who implement read/print with cin/cout, I think this would be better.

#ifdef FASTIO
template <int mod>
void read(modint<mod> &x) {
  read(x.val);
  assert(0 <= x.val && x.val < mod);
}
template <int mod>
void print(modint<mod> x) {
  print(x.val);
}
#endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.