Skip to content

Instantly share code, notes, and snippets.

View nachiketkanore's full-sized avatar
🖥️
Exploring Computer Science

Nachiket Kanore nachiketkanore

🖥️
Exploring Computer Science
View GitHub Profile
int solve(vector<int>& A, vector<int>& T) {
// total - number of sublists that contain target
// [1, 2, 3, 4, 5], T = [2, 4]
const int N = A.size();
const int MOD = 1e9 + 7;
const int INF = 1e9;
if (T.empty()) return 0;
sort(T.begin(), T.end());
long long tot = 1ll * N * (N + 1) / 2;
long long contain = 0;
-----------------------------------------------------------
-- Neovim settings
-----------------------------------------------------------
-----------------------------------------------------------
-- Neovim API aliases
-----------------------------------------------------------
--local map = vim.api.nvim_set_keymap -- set global keymap
local cmd = vim.cmd -- execute Vim commands
local exec = vim.api.nvim_exec -- execute Vimscript
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.294] Code complete: sema context TopLevel, query scopes [] (AnyScope=true), expected type <none>\n"
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.295] Code complete: 1 results from Sema, 13 from Index, 0 matched, 0 from identifiers, 14 returned.\n"
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.295] --> reply:textDocument/completion(26) 4 ms\n"
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.517] <-- textDocument/didChange\n"
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.669] <-- textDocument/didChange\n"
[ERROR][2021-12-06 20:16:25] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:25.862] <-- textDocument/didChange\n"
[ERROR][2021-12-06 20:16:26] .../vim/lsp/rpc.lua:417 "rpc" "clangd" "stderr" "I[20:16:26.192] <-- textDocument/didChange\n"
[ERROR]
void trace(int i, int j) {
if (i == n || j == m) return ;
int ans = go(i, j);
int c1 = 0;
if (s[i] == t[j]) {
c1 = 1 + go(i + 1, j + 1);
if (c1 == ans) {
cout << s[i];
int go(int i, int j) {
if (i == n || j == m) return 0;
int &ans = dp[i][j];
if (ans != -1) return ans;
ans = 0;
int c1 = 0;
if (s[i] == t[j]) {
int mat[N][N], colSum[N], n, m, x, y, dp[N][N][2];
int go(int id, int cx, int prev) {
if(cx > y)
return inf;
if(id > m)
return (cx >= x and cx <= y ? 0 : inf);
int& ans = dp[id][cx][prev];
if(~ans)
int go(int L, int R){
if(L > R)
return 0;
if(L == R)
return a[L];
int &ans = dp[L][R];
if(ans != -1)
return ans;
int dp[MAXN][MAXN]; // assign all to -1
int go(int id, int have){
if(have < 0)
return -inf;
if(id > n)
return 0;
int &ans = dp[id][have];
if(ans != -1)
@nachiketkanore
nachiketkanore / code.cpp
Created June 4, 2021 11:19
Dynamic Programming
int go(int id, int have){
if(have < 0)
return -inf;
if(id > n)
return 0;
int ans = -inf;
int take = 1 + go(id+1, have - c[id]);
int dont_take = go(id + 1, have);
ans = max({ans, take, dont_take});
@nachiketkanore
nachiketkanore / a.cpp
Created April 23, 2020 19:08 — forked from IvanIsCoding/a.cpp
Educational Dynamic Programming Contest - AtCoder
// Ivan Carvalho
// Problem A - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF = 2*1e9;
int dp[MAXN],N,K,h[MAXN];