forked from xcpcio/template-LaTeX-ECNU-F0RE1GNERS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2021564
commit 863704e
Showing
37 changed files
with
3,362 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# template-LaTeX-ECNU-F0RE1GNERS | ||
Build Code Library with LaTeX, base on [ECNU F0RE1GNERS template](https://github.com/F0RE1GNERS/template/tree/master). | ||
|
||
[PDF 下载](https://github.com/XCPCIO/template-LaTeX-ECNU-F0RE1GNERS/raw/gh-pages/template.pdf) | ||
|
||
[使用指北](https://xcpcio.com/code-library/code-library-build/#latex-ecnu-f0re1gners) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <filesystem> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
// 仅在下划线前面添加反斜杠进行转义 | ||
std::string escape_filename(const std::string& filename) { | ||
std::string safe_filename = filename; | ||
size_t pos = 0; | ||
while ((pos = safe_filename.find('_', pos)) != std::string::npos) { | ||
safe_filename.insert(pos, "\\"); // 在下划线前面插入反斜杠 | ||
pos += 2; // 更新位置,跳过新插入的字符 | ||
} | ||
return safe_filename; | ||
} | ||
|
||
int main() { | ||
const std::string output_filename = "listings.tex"; | ||
std::ofstream outfile(output_filename); | ||
|
||
if (!outfile.is_open()) { | ||
std::cerr << "Failed to open output file." << std::endl; | ||
return 1; | ||
} | ||
|
||
outfile << "% Generated LaTeX code for C++ file listings" << std::endl; | ||
outfile << "\\section{All}\n"; | ||
for (const auto& entry : fs::directory_iterator(".")) { | ||
const auto& path = entry.path(); | ||
if (entry.is_regular_file() && path.extension() == ".cpp") { | ||
std::string filename = path.filename().string(); | ||
std::string basename = escape_filename(filename); // 转义文件名 | ||
|
||
// 构造子章节标题,这里简单地使用转义后的文件名 | ||
std::string subsection_title = basename.substr(0, basename.size() - 4); | ||
|
||
// 输出到LaTeX文件 | ||
|
||
outfile << "\\subsection{" << subsection_title << "}\n"; | ||
outfile << "\\raggedbottom\\lstinputlisting[style=cpp]{assets/" << basename << "}\n"; // 假设.cpp文件在assets目录下 | ||
outfile << "\\hrulefill\n\n"; | ||
} | ||
} | ||
|
||
outfile.close(); | ||
std::cout << "LaTeX listings generated in " << output_filename << std::endl; | ||
return 0; | ||
} |
73 changes: 73 additions & 0 deletions
73
template-LaTeX-ECNU-F0RE1GNERS-main/assets/AC-Automaton.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include<iostream> | ||
#include<vector> | ||
#include<string.h> | ||
#include<algorithm> | ||
#include<map> | ||
#include<queue> | ||
#include<stack> | ||
#include<cmath> | ||
#include<set> | ||
#include<unordered_map> | ||
#include<deque> | ||
#include<iomanip> | ||
#include<bitset> | ||
#define ll long long | ||
#define int long long | ||
using namespace std; | ||
const int N=1e6+5; | ||
const int M=1e8+5; | ||
const int INF=1e9; | ||
const int p=998244353; | ||
const double DARW=0.97; | ||
int tree[N][30],bh,f[N],fail[N],ff[N],lst_[N]; | ||
queue<int>q; | ||
void insert(string s){ | ||
int p=0; | ||
for(int i=0;i<s.length();i++){ | ||
if(!tree[p][s[i]-'a'])tree[p][s[i]-'a']=++bh; | ||
p=tree[p][s[i]-'a']; | ||
} | ||
f[p]++; | ||
} | ||
void build(){ | ||
for(int i=0;i<26;i++)if(tree[0][i])q.push(tree[0][i]); | ||
while(!q.empty()){ | ||
int p=q.front(); | ||
q.pop(); | ||
for(int i=0;i<26;i++){ | ||
if(tree[p][i])q.push(tree[p][i]),fail[tree[p][i]]=tree[fail[p]][i]; | ||
else tree[p][i]=tree[fail[p]][i]; | ||
} | ||
} | ||
} | ||
void solve(){ | ||
int n; | ||
cin>>n; | ||
for(int i=1;i<=n;i++){ | ||
string ss; | ||
cin>>ss; | ||
insert(ss); | ||
} | ||
build(); | ||
string t; | ||
cin>>t; | ||
int ans=0; | ||
for(int i=0,j=0;i<t.length();i++){ | ||
j=tree[j][t[i]-'a']; | ||
for(int u=j;u&&!ff[u];u=fail[u]){ | ||
ans+=f[u],ff[u]=1; | ||
} | ||
} | ||
cout<<ans<<"\n"; | ||
} | ||
|
||
signed main(){ | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
cout.tie(0); | ||
int t=1,k=1; | ||
//cin>>t; | ||
while(t--){ | ||
solve(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
template-LaTeX-ECNU-F0RE1GNERS-main/assets/BarrettReduction.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct Mod | ||
{ | ||
long long m, p; | ||
void init(int pp) { m = ((__int128)1 << 64) / pp; p = pp; } | ||
long long operator ()(long long x){ | ||
return x - ((__int128(x) * m) >> 64) * p; | ||
} | ||
} mod; |
66 changes: 66 additions & 0 deletions
66
template-LaTeX-ECNU-F0RE1GNERS-main/assets/Binary heap.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include<iostream> | ||
#include<vector> | ||
#include<string.h> | ||
#include<algorithm> | ||
#include<map> | ||
#include<queue> | ||
#include<stack> | ||
#include<cmath> | ||
#include<set> | ||
#include<unordered_map> | ||
#include<deque> | ||
#include<iomanip> | ||
#include<bitset> | ||
#define ll long long | ||
#define int long long | ||
using namespace std; | ||
const int N=1e6+5; | ||
const int M=1e8+5; | ||
const int INF=1e9; | ||
const int p=998244353; | ||
const double DARW=0.97; | ||
int n,a[N]; | ||
void up(int x){ | ||
while(x/2&&a[x]<a[x/2]){ | ||
if(a[x]<a[x/2])swap(a[x],a[x/2]); | ||
x/=2; | ||
} | ||
} | ||
void down(int x){ | ||
while(2*x<=n){ | ||
int t=2*x; | ||
if(t+1<=n&&a[t+1]<a[t])t++; | ||
if(a[t]>=a[x])break; | ||
swap(a[t],a[x]); | ||
x=t; | ||
} | ||
} | ||
void build(){ | ||
for(int i=n;i>=1;i--)down(i); | ||
} | ||
void solve(){ | ||
int q; | ||
cin>>q; | ||
while(q--){ | ||
int op,x; | ||
cin>>op; | ||
if(op==1){ | ||
cin>>x; | ||
a[++n]=x; | ||
up(n); | ||
}else if(op==2)cout<<a[1]<<"\n"; | ||
else swap(a[1],a[n]),n--,down(1); | ||
} | ||
|
||
} | ||
|
||
signed main(){ | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
cout.tie(0); | ||
int t=1,k=1; | ||
//cin>>t; | ||
while(t--){ | ||
solve(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include<iostream> | ||
#include<vector> | ||
#include<string.h> | ||
#include<algorithm> | ||
#include<map> | ||
#include<queue> | ||
#include<stack> | ||
#include<cmath> | ||
#include<set> | ||
#include<unordered_map> | ||
#include<deque> | ||
#include<iomanip> | ||
#include<bitset> | ||
#include<functional> | ||
#include<bits/stdc++.h> | ||
#define ll long long | ||
#define int long long | ||
#define pii pair<int,int> | ||
using namespace std; | ||
const int N=2e5+5; | ||
const int M=5e6+5; | ||
const int INF=1e9; | ||
//const int p=998244353; | ||
const int MOD=1e9+7; | ||
const double DARW=0.97; | ||
const double eps=1e-12; | ||
int ans[N],f[N]; | ||
vector<int>t[N]; | ||
struct node{int x,val;bool operator<(const node& a)const{return val>a.val;}}; | ||
struct edge{int v,w;}; | ||
vector<edge>e[N]; | ||
priority_queue<node>q; | ||
void dij(){ | ||
while(q.size()&&f[q.top().x])q.pop(); | ||
if(q.empty())return; | ||
node x=q.top(); | ||
q.pop(); | ||
f[x.x]=1; | ||
for(auto u:e[x.x]){ | ||
if(u.w+ans[x.x]<ans[u.v]){ | ||
ans[u.v]=u.w+ans[x.x]; | ||
q.push({u.v,ans[u.v]}); | ||
} | ||
} | ||
dij(); | ||
} | ||
void solve(){ | ||
int h,a,b,c; | ||
cin>>h>>a>>b>>c; | ||
if(a<b)swap(a,b); | ||
if(b<c)swap(b,c); | ||
for(int i=0;i<c;i++)e[i].push_back({(i+a)%c,a}),e[i].push_back({(i+b)%c,b}),ans[i]=2e18; | ||
ans[0]=1; | ||
q.push({0,ans[0]}); | ||
dij(); | ||
int as=0; | ||
for(int i=0;i<c;i++){ | ||
if(h>=ans[i]) | ||
as+=(h-ans[i])/c+1; | ||
} | ||
cout<<as<<"\n"; | ||
} | ||
signed main(){ | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
cout.tie(0); | ||
int t=1,k=1; | ||
//cin>>t; | ||
while(t--)solve(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include<iostream> | ||
#include<vector> | ||
#include<string.h> | ||
#include<algorithm> | ||
#include<map> | ||
#include<queue> | ||
#include<stack> | ||
#include<cmath> | ||
#include<set> | ||
#include<unordered_map> | ||
#include<deque> | ||
#include<iomanip> | ||
#include<bitset> | ||
#include<functional> | ||
#include<bits/stdc++.h> | ||
#define ll long long | ||
#define int long long | ||
#define pii pair<int,int> | ||
using namespace std; | ||
const int N=5e5+5; | ||
const int M=5e6+5; | ||
const int INF=1e9; | ||
//const int p=998244353; | ||
const int MOD=1e9+7; | ||
const double DARW=0.97; | ||
const double eps=1e-12; | ||
int dp[N],a[20]; | ||
int gcd(int a,int b){ | ||
if(!b)return a; | ||
return gcd(b,a%b); | ||
} | ||
void solve(){ | ||
int n,l,r; | ||
cin>>n>>l>>r; | ||
for(int i=1;i<=n;i++)cin>>a[i]; | ||
for(int i=1;i<a[1];i++)dp[i]=2e18; | ||
dp[0]=0; | ||
for(int i=2;i<=n;i++){ | ||
for(int j=0,lim=gcd(a[i],a[1]);j<lim;j++){ | ||
for(int u=j,c=0;c<2;c+=(u==j)){ | ||
int p=(u+a[i])%a[1]; | ||
dp[p]=min(dp[p],dp[u]+a[i]); | ||
u=p; | ||
} | ||
} | ||
} | ||
int ans=0; | ||
for(int i=0;i<a[1];i++){ | ||
if(r>=dp[i])ans+=(r-dp[i])/a[1]+1; | ||
if(l>dp[i])ans-=(l-1-dp[i])/a[1]+1; | ||
} | ||
cout<<ans<<"\n"; | ||
} | ||
signed main(){ | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
cout.tie(0); | ||
int t=1,k=1; | ||
//cin>>t; | ||
while(t--)solve(); | ||
} |
Oops, something went wrong.