Skip to content

Commit

Permalink
Merge pull request #6 from tr1ten/dev
Browse files Browse the repository at this point in the history
Fix: Slow api fetching & releases
  • Loading branch information
tr1ten authored Oct 15, 2023
2 parents 1744a30 + b1799a6 commit 7c9dc9c
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file added public/logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions public/templates/2d_prefix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

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<vector<long long>>& 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<vector<int>>& mat, vector<vector<long long>>& 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;
}
19 changes: 19 additions & 0 deletions public/templates/binary_search_double.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 24 additions & 0 deletions public/templates/divisors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const int N = 1e5+5;
vector<vector<int>> divs(N+1);
// find prime <sqrt(MAX)
// O(LlogL)
void preprocess(){
for(int x=2;x<=N;x++){
for(int u=x;u<=N;u +=x){
divs[u].push_back(x);
}
}
}
vector<long long> divisors(long long x){
vector<long long> 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;
}
33 changes: 33 additions & 0 deletions public/templates/hashed_string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <bits/stdc++.h>

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<long long> pow;

// p_hash[i] is the hash of the first i characters of the given string
vector<long long> 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;
}
};
36 changes: 36 additions & 0 deletions public/templates/nCr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>

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;
}
34 changes: 33 additions & 1 deletion public/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
},
{
"id": 28,
"name": "Fenwick Tree",
"name": "Fast Pow",
"author": "tr1ten",
"language": "Cpp",
"published": "2021-01-01",
Expand Down Expand Up @@ -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"
}
]
2 changes: 1 addition & 1 deletion webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 7c9dc9c

Please sign in to comment.