diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f768333 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Regular release. + draft: false + prerelease: false \ No newline at end of file diff --git a/public/logo.jpeg b/public/logo.jpeg new file mode 100644 index 0000000..5b492d2 Binary files /dev/null and b/public/logo.jpeg differ diff --git a/public/templates/2d_prefix.cpp b/public/templates/2d_prefix.cpp new file mode 100644 index 0000000..b6728cd --- /dev/null +++ b/public/templates/2d_prefix.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +using namespace std; + +const long long MOD = 1e9+7; +const long long INF = 1e10+5; + +// Function to get sum from r1,c1 to r2,c2 from ps +long long get_sum(int r1, int c1, int r2, int c2, const vector>& ps) { + return ps[r1][c1] - (ps[r1][c2+1] + ps[r2+1][c1]) + ps[r2+1][c2+1]; +} + +// Function to fill the prefixes and check if x is ok +bool is_ok(long long x, int n, const vector>& mat, vector>& pref) { + // Reset and fill the prefixes + for (auto& v : pref) memset(&v[0], 0, sizeof(long long)*v.size()); + for (int i = n-1; i >= 0; i--) { + for (int j = n-1; j >= 0; j--) { + pref[i][j] = (mat[i][j] <= x) + pref[i+1][j] + pref[i][j+1] - pref[i+1][j+1]; + } + } + return true; +} diff --git a/public/templates/binary_search_double.cpp b/public/templates/binary_search_double.cpp new file mode 100644 index 0000000..bcb2e70 --- /dev/null +++ b/public/templates/binary_search_double.cpp @@ -0,0 +1,19 @@ +const long double eps = 1e-7; + +int main(int argc, char const *argv[]) +{ + double l = 0.0f, r=1e4f; + + double ans = -1; + int ic = 10000; + for (int i = 0; i < ic && l + eps < r; ++i) + { + float mid = 0.5f * (l + r); + if (ok(mid)){ + r = mid; + ans = mid;} + else + l = mid; + } + return 0; +} diff --git a/public/templates/divisors.cpp b/public/templates/divisors.cpp new file mode 100644 index 0000000..13b547d --- /dev/null +++ b/public/templates/divisors.cpp @@ -0,0 +1,24 @@ +const int N = 1e5+5; +vector> divs(N+1); +// find prime divisors(long long x){ + vector cur; + for(int j=1;j*j<=x;j++) + { + if(x%j==0) + { + cur.push_back(j); + if(j != x/j) + cur.push_back(x/j); + } + } + return cur; +} \ No newline at end of file diff --git a/public/templates/hashed_string.cpp b/public/templates/hashed_string.cpp new file mode 100644 index 0000000..ccf5858 --- /dev/null +++ b/public/templates/hashed_string.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + + + class HashedString { + private: + // change M and B if you want + static const long long M = 1e9 + 7; + static const long long B = 9973; + + // pow[i] contains B^i % M + static vector pow; + + // p_hash[i] is the hash of the first i characters of the given string + vector p_hash; + + public: + HashedString(const string &s) : p_hash(s.size() + 1) { + while (pow.size() < s.size()) { pow.push_back((pow.back() * B) % M); } + + p_hash[0] = 0; + for (int i = 0; i < s.size(); i++) { + p_hash[i + 1] = ((p_hash[i] * B) % M + s[i]) % M; + } + } + + long long getHash(int start, int end) { + long long raw_val = + (p_hash[end + 1] - (p_hash[start] * pow[end - start + 1])); + return (raw_val % M + M) % M; + } +}; \ No newline at end of file diff --git a/public/templates/nCr.cpp b/public/templates/nCr.cpp new file mode 100644 index 0000000..0157ae4 --- /dev/null +++ b/public/templates/nCr.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + +const long long MOD = 1e9+7; +const long long INF = 1e10+5; + +const int N = 1000 + 5; +long long fact[N]; +long long inv[N]; +long long finv[N]; + +void pre() { + fact[0] = 1; + for (int i = 1; i <= N; i++) { + fact[i] = (fact[i-1]*i)%MOD; + } + inv[1] = 1; + for (int i = 2; i <= N; i++) { + inv[i] = 1LL * (MOD - MOD / i) * inv[MOD % i] % MOD; + } + finv[0] = finv[1] = 1; + for (int i = 2; i <= N; i++) { + finv[i] = (inv[i]*finv[i-1])%MOD; + } +} + +long long nCk(int n,int k) { + return (((fact[n]*finv[k])%MOD)*finv[n-k])%MOD; +} + +int main(int argc, char const *argv[]) { + pre(); + cout << nCk(10,2); + return 0; +} \ No newline at end of file diff --git a/public/templates/templates.json b/public/templates/templates.json index 35febe1..b457922 100644 --- a/public/templates/templates.json +++ b/public/templates/templates.json @@ -217,7 +217,7 @@ }, { "id": 28, - "name": "Fenwick Tree", + "name": "Fast Pow", "author": "tr1ten", "language": "Cpp", "published": "2021-01-01", @@ -286,5 +286,37 @@ "language": "Cpp", "published": "2021-01-01", "src": "tarjan.cpp" + }, + { + "id":37, + "name":"2D Prefix", + "author":"tr1ten", + "language":"Cpp", + "published":"2022-09-15", + "src":"2d_prefix.cpp" + }, + { + "id":38, + "name":"Divisors", + "author":"tr1ten", + "language":"Cpp", + "published":"2022-09-15", + "src":"divisors.cpp" + }, + { + "id":39, + "name":"Combination nCr", + "author":"tr1ten", + "language":"Cpp", + "published":"2022-09-15", + "src":"nCr.cpp" + }, + { + "id":40, + "name":"Hashed String", + "author":"tr1ten", + "language":"Cpp", + "published":"2022-09-15", + "src":"hashed_string.cpp" } ] diff --git a/webpack.prod.js b/webpack.prod.js index 8cedbef..855ad9c 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -7,7 +7,7 @@ module.exports = merge(config, { plugins: [ new webpack.DefinePlugin({ BASE_URL: JSON.stringify( - "https://raw.githubusercontent.com/tr1ten/Neet/master/public/templates/" + "https://gitlab.com/neet3/Neet/-/raw/master/public/templates/" ), }), new CopyPlugin({