This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------- | |
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; |
NewerOlder