regular backup
This commit is contained in:
parent
2490f8091a
commit
61a74150f0
|
@ -14,8 +14,8 @@ in {
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
# Home Manager needs a bit of information about you and the paths it should
|
# Home Manager needs a bit of information about you and the paths it should
|
||||||
# manage.
|
# manage.
|
||||||
home.username = "user";
|
home.username = "nixos";
|
||||||
home.homeDirectory = "/home/user";
|
home.homeDirectory = "/home/nixos";
|
||||||
xdg.enable = true;
|
xdg.enable = true;
|
||||||
|
|
||||||
targets.genericLinux.enable = true;
|
targets.genericLinux.enable = true;
|
||||||
|
@ -34,13 +34,17 @@ in {
|
||||||
};
|
};
|
||||||
".gitconfig" = {
|
".gitconfig" = {
|
||||||
text = ''
|
text = ''
|
||||||
|
[core]
|
||||||
|
sshCommand = ssh.exe
|
||||||
[user]
|
[user]
|
||||||
email = arielherself@duck.com
|
email = arielherself@duck.com
|
||||||
name = arielherself
|
name = arielherself
|
||||||
[gpg "ssh"]
|
[gpg "ssh"]
|
||||||
program = ${pkgs._1password-gui}/bin/op-ssh-sign
|
program = "/mnt/c/Users/user/AppData/Local/1Password/app/8/op-ssh-sign.exe"
|
||||||
[safe]
|
[safe]
|
||||||
directory = /mnt/fdos_server/OS-24Fall-FDU
|
directory = /mnt/fdos_server/OS-24Fall-FDU
|
||||||
|
[credential]
|
||||||
|
helper = store
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
"Documents" = {
|
"Documents" = {
|
||||||
|
@ -50,6 +54,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
|
"ptool/ptool.toml" = {
|
||||||
|
source = "${config.home.homeDirectory}/Dropbox/arch/ptool.toml";
|
||||||
|
};
|
||||||
"nixpkgs/config.nix" = {
|
"nixpkgs/config.nix" = {
|
||||||
source = ../nixpkgs-config.nix;
|
source = ../nixpkgs-config.nix;
|
||||||
};
|
};
|
||||||
|
@ -83,6 +90,15 @@ in {
|
||||||
source = ../nvim;
|
source = ../nvim;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
};
|
};
|
||||||
|
"nvim/ftplugin/java.lua" = {
|
||||||
|
text = ''
|
||||||
|
local config = {
|
||||||
|
cmd = {'${pkgs.jdt-language-server}/bin/jdtls'},
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]),
|
||||||
|
}
|
||||||
|
require('jdtls').start_or_attach(config)
|
||||||
|
'';
|
||||||
|
};
|
||||||
"p10k/p10k.zsh" = {
|
"p10k/p10k.zsh" = {
|
||||||
source = ../p10k.zsh;
|
source = ../p10k.zsh;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
|
@ -91,21 +107,21 @@ in {
|
||||||
|
|
||||||
xdg.desktopEntries = {
|
xdg.desktopEntries = {
|
||||||
# Don't forget to change its permissions.
|
# Don't forget to change its permissions.
|
||||||
cider = {
|
# cider = {
|
||||||
name = "Cider";
|
# name = "Cider";
|
||||||
comment = "Apple Music Player";
|
# comment = "Apple Music Player";
|
||||||
type = "Application";
|
# type = "Application";
|
||||||
exec = "${pkgs.appimage-run}/bin/appimage-run ${config.home.homeDirectory}/Dropbox/arch/cider/Cider-linux-appimage-x64.AppImage";
|
# exec = "${pkgs.appimage-run}/bin/appimage-run ${config.home.homeDirectory}/Dropbox/arch/cider/Cider-linux-appimage-x64.AppImage";
|
||||||
terminal = false;
|
# terminal = false;
|
||||||
categories = [ "AudioVideo" "Audio" ];
|
# categories = [ "AudioVideo" "Audio" ];
|
||||||
};
|
# };
|
||||||
thorium = {
|
# thorium = {
|
||||||
name = "Thorium (AppImage)";
|
# name = "Thorium (AppImage)";
|
||||||
comment = "Access the Internet";
|
# comment = "Access the Internet";
|
||||||
type = "Application";
|
# type = "Application";
|
||||||
exec = "${pkgs.appimage-run}/bin/appimage-run ${config.home.homeDirectory}/Dropbox/arch/thorium/Thorium.AppImage";
|
# exec = "${pkgs.appimage-run}/bin/appimage-run ${config.home.homeDirectory}/Dropbox/arch/thorium/Thorium.AppImage";
|
||||||
terminal = false;
|
# terminal = false;
|
||||||
};
|
# };
|
||||||
};
|
};
|
||||||
|
|
||||||
# This value determines the Home Manager release that your configuration is
|
# This value determines the Home Manager release that your configuration is
|
||||||
|
@ -123,13 +139,14 @@ in {
|
||||||
# Terminal
|
# Terminal
|
||||||
# pkgs.contour
|
# pkgs.contour
|
||||||
# pkgs.tmux
|
# pkgs.tmux
|
||||||
pkgs.kitty
|
# pkgs.kitty
|
||||||
pkgs.alacritty
|
# pkgs.alacritty
|
||||||
|
|
||||||
# Networking
|
# Networking
|
||||||
pkgs.wireshark
|
# pkgs.wireshark
|
||||||
# pkgs.clash-verge-rev
|
# pkgs.clash-verge-rev
|
||||||
mypkgs.aria2
|
mypkgs.aria2
|
||||||
|
pkgs.qbittorrent-nox
|
||||||
|
|
||||||
# Editor
|
# Editor
|
||||||
unstable.neovim
|
unstable.neovim
|
||||||
|
@ -145,8 +162,8 @@ in {
|
||||||
pkgs.nodePackages.prettier
|
pkgs.nodePackages.prettier
|
||||||
unstable.markdown-oxide
|
unstable.markdown-oxide
|
||||||
pkgs.helix
|
pkgs.helix
|
||||||
unstable.zed-editor
|
# unstable.zed-editor
|
||||||
pkgs.xfce.mousepad
|
# pkgs.xfce.mousepad
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
pkgs.zip
|
pkgs.zip
|
||||||
|
@ -163,20 +180,20 @@ in {
|
||||||
pkgs.mtr
|
pkgs.mtr
|
||||||
pkgs.htop
|
pkgs.htop
|
||||||
pkgs.gdb
|
pkgs.gdb
|
||||||
mypkgs.dropbox
|
# mypkgs.dropbox
|
||||||
pkgs.brightnessctl
|
pkgs.brightnessctl
|
||||||
pkgs.psmisc
|
pkgs.psmisc
|
||||||
pkgs.xclip # Clipboard support
|
pkgs.xclip # Clipboard support
|
||||||
pkgs.vulkan-tools
|
# pkgs.vulkan-tools
|
||||||
pkgs.lshw # Hardware info
|
pkgs.lshw # Hardware info
|
||||||
unstable._1password
|
# unstable._1password
|
||||||
unstable._1password-gui
|
# unstable._1password-gui
|
||||||
pkgs.nix-index
|
pkgs.nix-index
|
||||||
pkgs.rclone
|
pkgs.rclone
|
||||||
pkgs.sshfs
|
pkgs.sshfs
|
||||||
pkgs.usbutils
|
# pkgs.usbutils
|
||||||
pkgs.udiskie
|
# pkgs.udiskie
|
||||||
pkgs.udisks
|
# pkgs.udisks
|
||||||
|
|
||||||
# Pwn
|
# Pwn
|
||||||
pkgs.nmap
|
pkgs.nmap
|
||||||
|
@ -185,6 +202,7 @@ in {
|
||||||
|
|
||||||
# Java
|
# Java
|
||||||
pkgs.jdk22
|
pkgs.jdk22
|
||||||
|
pkgs.jdt-language-server
|
||||||
|
|
||||||
# Python
|
# Python
|
||||||
(pkgs.python312.withPackages (ps: with ps; [
|
(pkgs.python312.withPackages (ps: with ps; [
|
||||||
|
@ -200,49 +218,50 @@ in {
|
||||||
# pkgs.waybar-mpris
|
# pkgs.waybar-mpris
|
||||||
|
|
||||||
# Desktop management
|
# Desktop management
|
||||||
pkgs.xfce.thunar
|
# pkgs.xfce.thunar
|
||||||
pkgs.baobab
|
# pkgs.baobab
|
||||||
pkgs.dua # CLI disk usage
|
pkgs.dua # CLI disk usage
|
||||||
pkgs.i3lock
|
# pkgs.i3lock
|
||||||
pkgs.flameshot
|
# pkgs.flameshot
|
||||||
|
|
||||||
# Note & Documents
|
# Note & Documents
|
||||||
pkgs.obsidian
|
# pkgs.obsidian
|
||||||
pkgs.xournalpp
|
# pkgs.xournalpp
|
||||||
pkgs.sioyek
|
# pkgs.sioyek
|
||||||
|
|
||||||
# Multimedia
|
# Multimedia
|
||||||
pkgs.kdePackages.gwenview # Image viewer
|
# pkgs.kdePackages.gwenview # Image viewer
|
||||||
pkgs.vlc
|
# pkgs.vlc
|
||||||
pkgs.playerctl
|
pkgs.playerctl
|
||||||
pkgs.jellyfin-ffmpeg
|
pkgs.jellyfin-ffmpeg
|
||||||
pkgs.spotify
|
# pkgs.spotify
|
||||||
unstable.spotify-player
|
# unstable.spotify-player
|
||||||
|
|
||||||
# Streaming
|
# Streaming
|
||||||
pkgs.obs-studio
|
# pkgs.obs-studio
|
||||||
|
|
||||||
# Communication
|
# Communication
|
||||||
pkgs.telegram-desktop
|
# pkgs.telegram-desktop
|
||||||
pkgs.discord
|
# pkgs.discord
|
||||||
|
|
||||||
# Browser
|
# Browser
|
||||||
pkgs.firefox-devedition
|
# pkgs.firefox-devedition
|
||||||
pkgs.chromium
|
# pkgs.chromium
|
||||||
mypkgs.thorium
|
# mypkgs.thorium
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
pkgs.fastfetch
|
pkgs.fastfetch
|
||||||
pkgs.onefetch
|
pkgs.onefetch
|
||||||
pkgs.lf # Terminal file manager
|
pkgs.lf # Terminal file manager
|
||||||
|
pkgs.lsof
|
||||||
pkgs.smassh # Typing test
|
pkgs.smassh # Typing test
|
||||||
pkgs.you-get # YouTube video downloader
|
pkgs.you-get # YouTube video downloader
|
||||||
pkgs.asciinema # Record terminal sessions
|
pkgs.asciinema # Record terminal sessions
|
||||||
pkgs.ulauncher # application launcher
|
# pkgs.ulauncher # application launcher
|
||||||
pkgs.networkmanagerapplet # Network manager tray icon
|
# pkgs.networkmanagerapplet # Network manager tray icon
|
||||||
pkgs.cbatticon # Battery tray icon
|
# pkgs.cbatticon # Battery tray icon
|
||||||
pkgs.pavucontrol # Volume control
|
# pkgs.pavucontrol # Volume control
|
||||||
pkgs.pasystray # Volume tray icon
|
# pkgs.pasystray # Volume tray icon
|
||||||
pkgs.yaru-theme
|
pkgs.yaru-theme
|
||||||
unstable.adwaita-icon-theme
|
unstable.adwaita-icon-theme
|
||||||
pkgs.adwaita-qt
|
pkgs.adwaita-qt
|
||||||
|
@ -251,13 +270,13 @@ in {
|
||||||
pkgs.asciiquarium # Interesting
|
pkgs.asciiquarium # Interesting
|
||||||
pkgs.starship # Prompt bar
|
pkgs.starship # Prompt bar
|
||||||
pkgs.patchelf
|
pkgs.patchelf
|
||||||
pkgs.screenkey
|
# pkgs.screenkey
|
||||||
|
|
||||||
# My version of BerkeleyMono NF is incomplete. Should add some fallback fonts.
|
# My version of BerkeleyMono NF is incomplete. Should add some fallback fonts.
|
||||||
(pkgs.nerdfonts.override { fonts = [
|
# (pkgs.nerdfonts.override { fonts = [
|
||||||
"JetBrainsMono"
|
# "JetBrainsMono"
|
||||||
"FiraCode"
|
# "FiraCode"
|
||||||
]; })
|
# ]; })
|
||||||
|
|
||||||
# # You can also create simple shell scripts directly inside your
|
# # You can also create simple shell scripts directly inside your
|
||||||
# # configuration. For example, this adds a command 'my-hello' to your
|
# # configuration. For example, this adds a command 'my-hello' to your
|
||||||
|
@ -334,7 +353,7 @@ in {
|
||||||
commit.gpgsign = true;
|
commit.gpgsign = true;
|
||||||
gpg.format = "ssh";
|
gpg.format = "ssh";
|
||||||
# This may not apply. Also try `git config --global gpg.ssh.program "/home/user/.nix-profile/bin/op-ssh-sign"`
|
# This may not apply. Also try `git config --global gpg.ssh.program "/home/user/.nix-profile/bin/op-ssh-sign"`
|
||||||
gpg."ssh".program = "${unstable._1password-gui}/bin/op-ssh-sign";
|
# gpg."ssh".program = "${unstable._1password-gui}/bin/op-ssh-sign";
|
||||||
push.autoSetupRemote = true;
|
push.autoSetupRemote = true;
|
||||||
core.editor = "nvim";
|
core.editor = "nvim";
|
||||||
};
|
};
|
||||||
|
@ -352,9 +371,13 @@ in {
|
||||||
shell = "${pkgs.zsh}/bin/zsh";
|
shell = "${pkgs.zsh}/bin/zsh";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
# Fix font variants and undercurl but optional.
|
# Fix font variants and undercurl but optional.
|
||||||
# set -ga terminal-overrides ",xterm-256color:Tc"
|
set -ga terminal-overrides ",xterm-256color:Tc"
|
||||||
# set-option -sa terminal-features ',xterm-256color:RGB'
|
# set-option -sa terminal-features ',xterm-256color:RGB'
|
||||||
# set-option -g default-terminal "tmux-256color"
|
# Fix Windows Terminal
|
||||||
|
set-option -g default-terminal "tmux-256color"
|
||||||
|
set-option -sa terminal-overrides ",xterm-256color:RGB"
|
||||||
|
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
||||||
|
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
||||||
# set-option -ga terminal-features ",xterm-256color:usstyle"
|
# set-option -ga terminal-features ",xterm-256color:usstyle"
|
||||||
# set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
# set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
||||||
# set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
# set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
||||||
|
@ -373,7 +396,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.wezterm = {
|
programs.wezterm = {
|
||||||
enable = true;
|
enable = false;
|
||||||
enableZshIntegration = true;
|
enableZshIntegration = true;
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
local config = wezterm.config_builder()
|
local config = wezterm.config_builder()
|
||||||
|
@ -411,5 +434,23 @@ in {
|
||||||
programs.home-manager = {
|
programs.home-manager = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.user.services.qbittorrent-nox = {
|
||||||
|
Unit = {
|
||||||
|
Description = "qBittorrent-nox service.";
|
||||||
|
# Wants = [ "network-online.target" ];
|
||||||
|
# After = [ "local-fs.target" "network-online.target" "nss-lookup.target" "multi-user.target" ];
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "default.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Type = "simple";
|
||||||
|
PrivateTmp = "false";
|
||||||
|
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox";
|
||||||
|
TimeoutStopSec = 1800;
|
||||||
|
Restart = "always";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
vim.cmd("set encoding=utf-8")
|
vim.cmd("set encoding=utf-8")
|
||||||
vim.cmd("set exrc")
|
vim.cmd("set exrc")
|
||||||
|
vim.cmd("set undofile")
|
||||||
|
vim.cmd("set undodir=~/.vim/undofiles")
|
||||||
|
vim.cmd("set undolevels=10000")
|
||||||
|
vim.cmd("set undoreload=50000")
|
||||||
vim.cmd("filetype off")
|
vim.cmd("filetype off")
|
||||||
vim.cmd("set pumblend=40")
|
vim.cmd("set pumblend=40")
|
||||||
vim.cmd("set winblend=40")
|
vim.cmd("set winblend=40")
|
||||||
|
@ -39,7 +43,7 @@ vim.diagnostic.config({
|
||||||
focusable = false,
|
focusable = false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
vim.cmd([[au CursorHold * lua vim.diagnostic.open_float(0,{scope = "cursor"})]])
|
-- vim.cmd([[au CursorHold * lua vim.diagnostic.open_float(0,{scope = "cursor"})]])
|
||||||
vim.g.mapleader = " ";
|
vim.g.mapleader = " ";
|
||||||
vim.filetype.add({
|
vim.filetype.add({
|
||||||
extension = {
|
extension = {
|
||||||
|
@ -151,12 +155,12 @@ local plugins = {
|
||||||
{
|
{
|
||||||
'jdhao/better-escape.vim' -- `jk` without causing `j` to have delay
|
'jdhao/better-escape.vim' -- `jk` without causing `j` to have delay
|
||||||
},
|
},
|
||||||
{
|
-- {
|
||||||
'Pocco81/auto-save.nvim',
|
-- 'Pocco81/auto-save.nvim',
|
||||||
opts = {
|
-- opts = {
|
||||||
enabled = true,
|
-- enabled = true,
|
||||||
}
|
-- }
|
||||||
},
|
-- },
|
||||||
{
|
{
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
|
@ -485,6 +489,7 @@ local plugins = {
|
||||||
},
|
},
|
||||||
{ 'NStefan002/screenkey.nvim' },
|
{ 'NStefan002/screenkey.nvim' },
|
||||||
{ 'kosayoda/nvim-lightbulb' },
|
{ 'kosayoda/nvim-lightbulb' },
|
||||||
|
{ 'mfussenegger/nvim-jdtls' }, -- Java LS
|
||||||
}
|
}
|
||||||
require("lazy").setup(plugins, {})
|
require("lazy").setup(plugins, {})
|
||||||
|
|
||||||
|
@ -545,7 +550,7 @@ require('search').setup {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vim.keymap.set('n', '<leader>o', '<Cmd>lua require("search").open({ tab_name = "Smart Open" })<CR>')
|
vim.keymap.set('n', '<leader>o', '<Cmd>lua require("search").open({ tab_name = "Files" })<CR>')
|
||||||
vim.keymap.set('n', '<leader>f', '<Cmd>lua require("search").open({ tab_name = "Symbols" })<CR>')
|
vim.keymap.set('n', '<leader>f', '<Cmd>lua require("search").open({ tab_name = "Symbols" })<CR>')
|
||||||
vim.keymap.set('n', '<leader>g', '<Cmd>lua require("search").open({ tab_name = "Grep" })<CR>')
|
vim.keymap.set('n', '<leader>g', '<Cmd>lua require("search").open({ tab_name = "Grep" })<CR>')
|
||||||
|
|
||||||
|
@ -654,7 +659,9 @@ lspconfig.clangd.setup {
|
||||||
end,
|
end,
|
||||||
cmd = {
|
cmd = {
|
||||||
"clangd",
|
"clangd",
|
||||||
-- "--header-insertion=never"
|
-- "--header-insertion=never",
|
||||||
|
"--clang-tidy",
|
||||||
|
"--clang-tidy-checks=*",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lspconfig.pyright.setup {
|
lspconfig.pyright.setup {
|
||||||
|
@ -787,6 +794,8 @@ vim.keymap.set('n', '<leader>x', require("mini.trailspace").trim, {noremap=true}
|
||||||
vim.keymap.set('n', '<Del>', vim.notify.dismiss, {noremap=true})
|
vim.keymap.set('n', '<Del>', vim.notify.dismiss, {noremap=true})
|
||||||
vim.keymap.set({'n', 'v', 'x'}, 'Q', 'q', {noremap=true})
|
vim.keymap.set({'n', 'v', 'x'}, 'Q', 'q', {noremap=true})
|
||||||
vim.keymap.set({'n', 'v', 'x'}, 'q', '<Nop>', {noremap=true})
|
vim.keymap.set({'n', 'v', 'x'}, 'q', '<Nop>', {noremap=true})
|
||||||
|
vim.keymap.set('n', 'g ', [[/\v^\s+$<CR>$<Cmd>nohlsearch<CR>]], {noremap=true, silent=true})
|
||||||
|
vim.keymap.set('n', 'gy', "`[v`]", {noremap=true})
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('SearchInCurrentFile', function()
|
vim.api.nvim_create_user_command('SearchInCurrentFile', function()
|
||||||
vim.ui.input({ prompt = 'Grep ...'}, function(input)
|
vim.ui.input({ prompt = 'Grep ...'}, function(input)
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
return [=[
|
||||||
|
// INFO: This function treats vertex pairs that have multiple edges as eBCCs.
|
||||||
|
//
|
||||||
|
// Returns: (BCC count, indices of BCC of each vertex)
|
||||||
|
//
|
||||||
|
// BCC index starts from 1
|
||||||
|
pair<int, vector<int>> ebcc_with_mult(const vector<vector<pii>>& ch) {
|
||||||
|
int n = ch.size() - 1;
|
||||||
|
vector<int> c(n + 1);
|
||||||
|
|
||||||
|
vector<int> low(n + 1), dfn(n + 1);
|
||||||
|
vector<bool> vis(n + 1);
|
||||||
|
vector<int> stack;
|
||||||
|
|
||||||
|
int time = 0;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
auto dfs = [&] (auto dfs, int v, int prev_idx) -> void {
|
||||||
|
low[v] = dfn[v] = ++time;
|
||||||
|
stack.emplace_back(v);
|
||||||
|
vis[v] = 1;
|
||||||
|
for (auto&& [u, i] : ch[v]) {
|
||||||
|
if (i == prev_idx) continue;
|
||||||
|
if (not dfn[u]) {
|
||||||
|
dfs(dfs, u, i);
|
||||||
|
chmin(low[v], low[u]);
|
||||||
|
} else if (vis[u]) {
|
||||||
|
chmin(low[v], dfn[u]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dfn[v] == low[v]) {
|
||||||
|
cnt += 1;
|
||||||
|
c[v] = cnt;
|
||||||
|
while (stack.back() != v) {
|
||||||
|
c[stack.back()] = cnt;
|
||||||
|
vis[stack.back()] = 0;
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; ++i) {
|
||||||
|
if (not dfn[i]) {
|
||||||
|
dfs(dfs, i, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { cnt, c };
|
||||||
|
}
|
||||||
|
|
||||||
|
]=]
|
|
@ -0,0 +1,51 @@
|
||||||
|
return [=[
|
||||||
|
// WARN: Input should be a simple graph
|
||||||
|
//
|
||||||
|
// Returns: (BCC count, indices of BCC of each vertex)
|
||||||
|
//
|
||||||
|
// BCC index starts from 1
|
||||||
|
pair<int, vector<int>> ebcc(const vector<vector<int>>& ch) {
|
||||||
|
int n = ch.size() - 1;
|
||||||
|
vector<int> c(n + 1);
|
||||||
|
|
||||||
|
vector<int> low(n + 1), dfn(n + 1);
|
||||||
|
vector<bool> vis(n + 1);
|
||||||
|
vector<int> stack;
|
||||||
|
|
||||||
|
int time = 0;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
auto dfs = [&] (auto dfs, int v, int pa) -> void {
|
||||||
|
low[v] = dfn[v] = ++time;
|
||||||
|
stack.emplace_back(v);
|
||||||
|
vis[v] = 1;
|
||||||
|
for (auto&& u : ch[v]) {
|
||||||
|
if (u == pa) continue;
|
||||||
|
if (not dfn[u]) {
|
||||||
|
dfs(dfs, u, v);
|
||||||
|
chmin(low[v], low[u]);
|
||||||
|
} else if (vis[u]) {
|
||||||
|
chmin(low[v], dfn[u]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dfn[v] == low[v]) {
|
||||||
|
cnt += 1;
|
||||||
|
c[v] = cnt;
|
||||||
|
while (stack.back() != v) {
|
||||||
|
c[stack.back()] = cnt;
|
||||||
|
vis[stack.back()] = 0;
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
stack.pop_back();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; ++i) {
|
||||||
|
if (not dfn[i]) {
|
||||||
|
dfs(dfs, i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { cnt, c };
|
||||||
|
}
|
||||||
|
|
||||||
|
]=]
|
|
@ -74,7 +74,7 @@ struct range_hash {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
range_hash(const T& vec) {
|
range_hash(const T& vec) {
|
||||||
hp.emplace_back();
|
hp.emplace_back();
|
||||||
hash_vec<ll> hs(vec.size());
|
hash_vec<ll> hs(vec.size() + 1);
|
||||||
for (auto&& x : vec) {
|
for (auto&& x : vec) {
|
||||||
hs.push_back(x);
|
hs.push_back(x);
|
||||||
hp.emplace_back(hs.hash());
|
hp.emplace_back(hs.hash());
|
||||||
|
|
|
@ -366,3 +366,42 @@ ls.add_snippets(nil, {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local ebcc = require('snippets.ebcc')
|
||||||
|
ls.add_snippets(nil, {
|
||||||
|
cpp = {
|
||||||
|
snip({
|
||||||
|
trig = 'ebcc',
|
||||||
|
namr = 'ebcc',
|
||||||
|
dscr = 'eBCC on simple undirected graph',
|
||||||
|
},{
|
||||||
|
text(lines(ebcc))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local ebcc_with_mult = require('snippets.ebcc-with-mult')
|
||||||
|
ls.add_snippets(nil, {
|
||||||
|
cpp = {
|
||||||
|
snip({
|
||||||
|
trig = 'ebcc_with_mult',
|
||||||
|
namr = 'ebcc_with_mult',
|
||||||
|
dscr = 'eBCC on common undirected graph (with multiple edges)',
|
||||||
|
},{
|
||||||
|
text(lines(ebcc_with_mult))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local manacher = require('snippets.manacher')
|
||||||
|
ls.add_snippets(nil, {
|
||||||
|
cpp = {
|
||||||
|
snip({
|
||||||
|
trig = 'manacher',
|
||||||
|
namr = 'manacher',
|
||||||
|
dscr = 'Manacher algorithm for counting palindrome substrings',
|
||||||
|
},{
|
||||||
|
text(lines(manacher))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
return [=[
|
||||||
|
template <typename T>
|
||||||
|
vector<int> manacher(const vector<T>& s, const T& never) {
|
||||||
|
vector<T> t = { never };
|
||||||
|
for (auto&& c : s) {
|
||||||
|
t.emplace_back(c);
|
||||||
|
t.emplace_back(never);
|
||||||
|
}
|
||||||
|
int n = t.size();
|
||||||
|
vector<int> r(n);
|
||||||
|
for (int i = 0, j = 0; i < n; ++i) {
|
||||||
|
if (2 * j - i >= 0 && j + r[j] > i) {
|
||||||
|
r[i] = min(r[2 * j - i], j + r[j] - i);
|
||||||
|
}
|
||||||
|
while (i - r[i] >= 0 && i + r[i] < n && t[i - r[i]] == t[i + r[i]]) {
|
||||||
|
r[i] += 1;
|
||||||
|
}
|
||||||
|
if (i + r[i] > j + r[j]) {
|
||||||
|
j = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n; i += 2) {
|
||||||
|
r[i] = (r[i] - 1) / 2;
|
||||||
|
}
|
||||||
|
for (int i = 1; i < n; i += 2) {
|
||||||
|
r[i] /= 2;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
]=]
|
|
@ -8,19 +8,15 @@ struct mcmf {
|
||||||
int rev;
|
int rev;
|
||||||
int mark;
|
int mark;
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<vector<edge>> edges;
|
vector<vector<edge>> edges;
|
||||||
vector<ll> dis;
|
vector<ll> dis;
|
||||||
vector<bool> vis;
|
vector<bool> vis;
|
||||||
ll ret;
|
ll ret;
|
||||||
|
|
||||||
mcmf(int n) : edges(n + 1), dis(n + 1), vis(n + 1) {}
|
mcmf(int n) : edges(n + 1), dis(n + 1), vis(n + 1) {}
|
||||||
|
|
||||||
void add_edge(int from, int to, ll cap, ll cost, int mark = 0, int mark_rev = 0) {
|
void add_edge(int from, int to, ll cap, ll cost, int mark = 0, int mark_rev = 0) {
|
||||||
edges[from].push_back({ to, cap, 0, cost, int(edges[to].size()), mark });
|
edges[from].push_back({ to, cap, 0, cost, int(edges[to].size()), mark });
|
||||||
edges[to].push_back({ from, 0, 0, -cost, int(edges[from].size() - 1), mark_rev });
|
edges[to].push_back({ from, 0, 0, -cost, int(edges[from].size() - 1), mark_rev });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sp(int s, int t) {
|
bool sp(int s, int t) {
|
||||||
dis.assign(edges.size(), INFLL);
|
dis.assign(edges.size(), INFLL);
|
||||||
dis[s] = 0;
|
dis[s] = 0;
|
||||||
|
@ -39,7 +35,6 @@ struct mcmf {
|
||||||
}
|
}
|
||||||
return dis[t] != INFLL;
|
return dis[t] != INFLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ll dfs(int s, int t, ll cap) {
|
ll dfs(int s, int t, ll cap) {
|
||||||
if (vis[s]) {
|
if (vis[s]) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,7 +60,6 @@ struct mcmf {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns: (flow, cost)
|
// returns: (flow, cost)
|
||||||
pll run(int s, int t) {
|
pll run(int s, int t) {
|
||||||
ll res = 0; ret = 0;
|
ll res = 0; ret = 0;
|
||||||
|
@ -73,6 +67,9 @@ struct mcmf {
|
||||||
vis.assign(edges.size(), 0);
|
vis.assign(edges.size(), 0);
|
||||||
ll curr = dfs(s, t, LLONG_MAX);
|
ll curr = dfs(s, t, LLONG_MAX);
|
||||||
res += curr;
|
res += curr;
|
||||||
|
// BUG: this is a temporary fix of the infinite-looping issue observed
|
||||||
|
// when dealing with networks with negative weights.
|
||||||
|
if (curr == 0) break;
|
||||||
}
|
}
|
||||||
return { res, ret };
|
return { res, ret };
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ return [[
|
||||||
template<typename _Tp, typename _Op = function<_Tp(const _Tp&, const _Tp&)>> struct sparse_table {
|
template<typename _Tp, typename _Op = function<_Tp(const _Tp&, const _Tp&)>> struct sparse_table {
|
||||||
_Op op;
|
_Op op;
|
||||||
vector<vector<_Tp>> st;
|
vector<vector<_Tp>> st;
|
||||||
|
sparse_table() {}
|
||||||
template <typename ReverseIterator>
|
template <typename ReverseIterator>
|
||||||
sparse_table(ReverseIterator __first, ReverseIterator __last, _Op&& __operation) {
|
sparse_table(ReverseIterator __first, ReverseIterator __last, _Op&& __operation) {
|
||||||
op = __operation;
|
op = __operation;
|
||||||
|
|
Loading…
Reference in New Issue