【樹上倍增 LCA DFS 前綴和】P10391 [藍橋杯 2024 省 A] 零食采購|普及+

本文涉及知識點

C++算法:前綴和、前綴乘積、前綴異或的原理、源碼及測試用例 包括課程視頻
C++DFS
樹上倍增 LCA

P10391 [藍橋杯 2024 省 A] 零食采購

題目描述

小藍準備去星際旅行,出發前想在本星系采購一些零食,星系內有 nnn 顆星球,由 n?1n-1n?1 條航路連接為連通圖,第 iii 顆星球賣第 cic_ici? 種零食特產。小藍想出了 qqq 個采購方案,第 iii 個方案的起點為星球 sis_isi? ,終點為星球 tit_iti? ,對于每種采購方案,小藍將從起點走最短的航路到終點,并且可以購買所有經過的星球上的零食(包括起點終點),請計算每種采購方案最多能買多少種不同的零食。

輸入格式

輸入的第一行包含兩個正整數 nnnqqq,用一個空格分隔。
第二行包含 nnn 個整數 c1,c2,?,cnc_1,c_2,\cdots, c_nc1?,c2?,?,cn?,相鄰整數之間使用一個空格分隔。
接下來 n?1n - 1n?1 行,第 iii 行包含兩個整數 ui,viu_i,v_iui?,vi?,用一個空格分隔,表示一條
航路將星球 uiu_iui?viv_ivi? 相連。
接下來 qqq 行,第 iii 行包含兩個整數 $s_i
, t_i $,用一個空格分隔,表示一個采購方案。

輸出格式

輸出 qqq 行,每行包含一個整數,依次表示每個采購方案的答案。

輸入輸出樣例 #1

輸入 #1

4 2
1 2 3 1
1 2
1 3
2 4
4 3
1 4

輸出 #1

3
2

說明/提示

第一個方案路線為 {4,2,1,3}\{4, 2, 1, 3\}{4,2,1,3},可以買到第 1,2,31, 2, 31,2,3 種零食;
第二個方案路線為 {1,2,4}\{1, 2, 4\}{1,2,4},可以買到第 1,21, 21,2 種零食。

對于 20% 的評測用例,$1 ≤ n, q ≤ 5000 $;
對于所有評測用例,1≤n,q≤105,1≤ci≤20,1≤ui,vi≤n,1≤si,ti≤n1 ≤ n, q ≤ 10^5,1 ≤ c_i ≤ 20,1 ≤ u_i , v_i ≤ n,1 ≤ s_i , t_i ≤ n1n,q1051ci?201ui?,vi?n1si?,ti?n

DFS 樹上前綴和 LCA

以1(0)為根,cnt[i][j]記錄第j個星球是否有貨物i。preSum[i][j],節點j到根節點整個路徑包括貨物i的星球數量。初始化只需要一次DFS。時間復雜度:O(20n)
每次查詢,令u和v的最近公共祖先g,如果preSum[i][u]+preSum[i][v]-2preSum[i][g]+cnt[i][g] > 0,則可以買到貨物i。
是否復雜度:O(20qlogn)

代碼

核心代碼

#include <iostream>
#include <sstream>
#include <vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<string>
#include<algorithm>
#include<functional>
#include<queue>
#include <stack>
#include<iomanip>
#include<numeric>
#include <math.h>
#include <climits>
#include<assert.h>
#include<cstring>
#include<list>
#include<array>#include <bitset>
using namespace std;template<class T1, class T2>
std::istream& operator >> (std::istream& in, pair<T1, T2>& pr) {in >> pr.first >> pr.second;return in;
}template<class T1, class T2, class T3 >
std::istream& operator >> (std::istream& in, tuple<T1, T2, T3>& t) {in >> get<0>(t) >> get<1>(t) >> get<2>(t);return in;
}template<class T1, class T2, class T3, class T4 >
std::istream& operator >> (std::istream& in, tuple<T1, T2, T3, T4>& t) {in >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t);return in;
}template<class T1, class T2, class T3, class T4, class T5, class T6, class T7 >
std::istream& operator >> (std::istream& in, tuple<T1, T2, T3, T4,T5,T6,T7>& t) {in >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t) >> get<4>(t) >> get<5>(t) >> get<6>(t);return in;
}template<class T = int>
vector<T> Read() {int n;cin >> n;vector<T> ret(n);for (int i = 0; i < n; i++) {cin >> ret[i];}return ret;
}
template<class T = int>
vector<T> ReadNotNum() {vector<T> ret;T tmp;while (cin >> tmp) {ret.emplace_back(tmp);if ('\n' == cin.get()) { break; }}return ret;
}template<class T = int>
vector<T> Read(int n) {vector<T> ret(n);for (int i = 0; i < n; i++) {cin >> ret[i];}return ret;
}template<int N = 1'000'000>
class COutBuff
{
public:COutBuff() {m_p = puffer;}template<class T>void write(T x) {int num[28], sp = 0;if (x < 0)*m_p++ = '-', x = -x;if (!x)*m_p++ = 48;while (x)num[++sp] = x % 10, x /= 10;while (sp)*m_p++ = num[sp--] + 48;AuotToFile();}void writestr(const char* sz) {strcpy(m_p, sz);m_p += strlen(sz);AuotToFile();}inline void write(char ch){*m_p++ = ch;AuotToFile();}inline void ToFile() {fwrite(puffer, 1, m_p - puffer, stdout);m_p = puffer;}~COutBuff() {ToFile();}
private:inline void AuotToFile() {if (m_p - puffer > N - 100) {ToFile();}}char  puffer[N], * m_p;
};template<int N = 1'000'000>
class CInBuff
{
public:inline CInBuff() {}inline CInBuff<N>& operator>>(char& ch) {FileToBuf();while (('\r' == *S) || ('\n' == *S) || (' ' == *S)) { S++; }//忽略空格和回車ch = *S++;return *this;}inline CInBuff<N>& operator>>(int& val) {FileToBuf();int x(0), f(0);while (!isdigit(*S))f |= (*S++ == '-');while (isdigit(*S))x = (x << 1) + (x << 3) + (*S++ ^ 48);val = f ? -x : x; S++;//忽略空格換行		return *this;}inline CInBuff& operator>>(long long& val) {FileToBuf();long long x(0); int f(0);while (!isdigit(*S))f |= (*S++ == '-');while (isdigit(*S))x = (x << 1) + (x << 3) + (*S++ ^ 48);val = f ? -x : x; S++;//忽略空格換行return *this;}template<class T1, class T2>inline CInBuff& operator>>(pair<T1, T2>& val) {*this >> val.first >> val.second;return *this;}template<class T1, class T2, class T3>inline CInBuff& operator>>(tuple<T1, T2, T3>& val) {*this >> get<0>(val) >> get<1>(val) >> get<2>(val);return *this;}template<class T1, class T2, class T3, class T4>inline CInBuff& operator>>(tuple<T1, T2, T3, T4>& val) {*this >> get<0>(val) >> get<1>(val) >> get<2>(val) >> get<3>(val);return *this;}template<class T = int>inline CInBuff& operator>>(vector<T>& val) {int n;*this >> n;val.resize(n);for (int i = 0; i < n; i++) {*this >> val[i];}return *this;}template<class T = int>vector<T> Read(int n) {vector<T> ret(n);for (int i = 0; i < n; i++) {*this >> ret[i];}return ret;}template<class T = int>vector<T> Read() {vector<T> ret;*this >> ret;return ret;}
private:inline void FileToBuf() {const int canRead = m_iWritePos - (S - buffer);if (canRead >= 100) { return; }if (m_bFinish) { return; }for (int i = 0; i < canRead; i++){buffer[i] = S[i];//memcpy出錯			}m_iWritePos = canRead;buffer[m_iWritePos] = 0;S = buffer;int readCnt = fread(buffer + m_iWritePos, 1, N - m_iWritePos, stdin);if (readCnt <= 0) { m_bFinish = true; return; }m_iWritePos += readCnt;buffer[m_iWritePos] = 0;S = buffer;}int m_iWritePos = 0; bool m_bFinish = false;char buffer[N + 10], * S = buffer;
};class CNeiBo
{
public:static vector<vector<int>> Two(int n, const vector<pair<int, int>>& edges, bool bDirect, int iBase = 0){vector<vector<int>>  vNeiBo(n);for (const auto& [i1, i2] : edges){vNeiBo[i1 - iBase].emplace_back(i2 - iBase);if (!bDirect){vNeiBo[i2 - iBase].emplace_back(i1 - iBase);}}return vNeiBo;}static vector<vector<int>> Two(int n, const vector<vector<int>>& edges, bool bDirect, int iBase = 0){vector<vector<int>>  vNeiBo(n);for (const auto& v : edges){vNeiBo[v[0] - iBase].emplace_back(v[1] - iBase);if (!bDirect){vNeiBo[v[1] - iBase].emplace_back(v[0] - iBase);}}return vNeiBo;}static vector<vector<std::pair<int, int>>> Three(int n, vector<vector<int>>& edges, bool bDirect, int iBase = 0){vector<vector<std::pair<int, int>>> vNeiBo(n);for (const auto& v : edges){vNeiBo[v[0] - iBase].emplace_back(v[1] - iBase, v[2]);if (!bDirect){vNeiBo[v[1] - iBase].emplace_back(v[0] - iBase, v[2]);}}return vNeiBo;}static vector<vector<std::pair<int, int>>> Three(int n, const vector<tuple<int, int, int>>& edges, bool bDirect, int iBase = 0){vector<vector<std::pair<int, int>>> vNeiBo(n);for (const auto& [u, v, w] : edges){vNeiBo[u - iBase].emplace_back(v - iBase, w);if (!bDirect){vNeiBo[v - iBase].emplace_back(u - iBase, w);}}return vNeiBo;}static vector<vector<int>> Mat(vector<vector<int>>& neiBoMat){vector<vector<int>> neiBo(neiBoMat.size());for (int i = 0; i < neiBoMat.size(); i++){for (int j = i + 1; j < neiBoMat.size(); j++){if (neiBoMat[i][j]){neiBo[i].emplace_back(j);neiBo[j].emplace_back(i);}}}return neiBo;}
};class CBFSLeve {
public:static vector<int> Leve(const vector<vector<int>>& neiBo, vector<int> start) {vector<int> leves(neiBo.size(), -1);for (const auto& s : start) {leves[s] = 0;}for (int i = 0; i < start.size(); i++) {for (const auto& next : neiBo[start[i]]) {if (-1 != leves[next]) { continue; }leves[next] = leves[start[i]] + 1;start.emplace_back(next);}}return leves;}template<class NextFun>static vector<int> Leve(int N, NextFun nextFun, vector<int> start) {vector<int> leves(N, -1);for (const auto& s : start) {leves[s] = 0;}for (int i = 0; i < start.size(); i++) {auto nexts = nextFun(start[i]);for (const auto& next : nexts) {if (-1 != leves[next]) { continue; }leves[next] = leves[start[i]] + 1;start.emplace_back(next);}}return leves;}static vector<vector<int>> LeveNodes(const vector<int>& leves) {const int iMaxLeve = *max_element(leves.begin(), leves.end());vector<vector<int>> ret(iMaxLeve + 1);for (int i = 0; i < leves.size(); i++) {ret[leves[i]].emplace_back(i);}return ret;};static vector<int> LeveSort(const vector<int>& leves) {const int iMaxLeve = *max_element(leves.begin(), leves.end());vector<vector<int>> leveNodes(iMaxLeve + 1);for (int i = 0; i < leves.size(); i++) {leveNodes[leves[i]].emplace_back(i);}vector<int> ret;for (const auto& v : leveNodes) {ret.insert(ret.end(), v.begin(), v.end());}return ret;};
};
class CParents
{
public:CParents(vector<int>& vParent, long long iMaxDepth){int iBitNum = 0;for (; iMaxDepth; iBitNum++) {const auto mask = 1LL << iBitNum;if (mask & iMaxDepth) { iMaxDepth = iMaxDepth ^ mask; }}const int n = vParent.size();m_vParents.assign(iBitNum + 1, vector<int>(n, -1));m_vParents[0] = vParent;//樹上倍增for (int i = 1; i < m_vParents.size(); i++){for (int j = 0; j < n; j++){const int iPre = m_vParents[i - 1][j];if (-1 != iPre){m_vParents[i][j] = m_vParents[i - 1][iPre];}}}}int GetParent(int iNode, int iDepth)const{int iParent = iNode;for (int iBit = 0; iBit < m_vParents.size(); iBit++){if (-1 == iParent){return iParent;}if (iDepth & (1 << iBit)){iParent = m_vParents[iBit][iParent];}}return iParent;}inline int GetBitCnt()const { return m_vParents.size(); };inline const int& GetPow2Parent(int iNode, int n)const {return m_vParents[n][iNode];}//在leftNodeExclude的1到rightLeve級祖先中查找符合pr的最近祖先template<class _Pr>int FindFirst(int leftNodeExclude, int rightLeve, _Pr pr) {for (int iBit = GetBitCnt() - 1; iBit >= 0; iBit--) {const int iMask = 1 << iBit;if (!(iMask & rightLeve)) { continue; }if (pr(m_vParents[iBit][leftNodeExclude])) {return BFindFirst(leftNodeExclude, iBit, pr);}leftNodeExclude = m_vParents[iBit][leftNodeExclude];}return -1;}//在node的0到rightLeve級祖先中查找符合pr的最遠祖先比node高多少層次,這些層次必須存在template<class _Pr>int FindEnd(int node, int rightLeve, _Pr pr) {int leve = 0;for (int iBit = GetBitCnt() - 1; iBit >= 0; iBit--) {const int iMask = 1 << iBit;if (!(iMask & rightLeve)) { continue; }if (!pr(m_vParents[iBit][node])) {return leve + BFindEnd(node, iBit, pr);}node = m_vParents[iBit][node];leve = leve ^ iMask;}return leve;}
protected://在leftNodeExclude的1到2^pow^級祖先中查找符合pr的最近祖先template<class _Pr>int BFindFirst(int leftNodeExclude, int pow, _Pr pr) {while (pow > 0) {const int& mid = m_vParents[pow - 1][leftNodeExclude];if (pr(mid)) {}else {leftNodeExclude = mid;}pow--;}return m_vParents[0][leftNodeExclude];}//在node的[0,2^pow^-1]級祖先中尋找符合的最后一個template<class _Pr>int BFindEnd(int node, int pow, _Pr pr) {int leve = 0;while (pow > 0) {pow--;const int& mid = m_vParents[pow][node];if (pr(mid)) {node = mid;leve = leve ^ (1 << pow);}else {}}return leve;}vector<vector<int>> m_vParents;
};class C2Parents : public CParents
{
public:C2Parents(vector<int>& vParent, const vector<int>& vDepth) :m_vDepth(vDepth), CParents(vParent, *std::max_element(vDepth.begin(), vDepth.end())){}int GetPublicParent(int iNode1, int iNode2)const{int leve0 = m_vDepth[iNode1];int leve1 = m_vDepth[iNode2];if (leve0 < leve1){iNode2 = GetParent(iNode2, leve1 - leve0);leve1 = leve0;}else{iNode1 = GetParent(iNode1, leve0 - leve1);leve0 = leve1;}if (iNode1 == iNode2) { return iNode1; }for (int iBit = GetBitCnt() - 1; iBit >= 0; iBit--) {const int iMask = 1 << iBit;if (iMask & leve0) {const int i1 = GetPow2Parent(iNode1, iBit);const int i2 = GetPow2Parent(iNode2, iBit);if (i1 == i2) {while (iBit > 0) {const int i3 = GetPow2Parent(iNode1, iBit - 1);const int i4 = GetPow2Parent(iNode2, iBit - 1);if (i3 != i4) {iNode1 = i3; iNode2 = i4;}iBit--;}return GetPow2Parent(iNode1, 0);}else {iNode1 = i1; iNode2 = i2; leve0 -= iMask;}}}return iNode1;}
protected:vector<vector<int>> m_vParents;const vector<int> m_vDepth;
};
class Solution {
public:vector<int> Ans(const int N, vector<int>& c, vector<pair<int, int>>& edge, vector<pair<int, int>>& que) {auto neiBo = CNeiBo::Two(N, edge, false, 1);vector<vector<int>> cnt(20, vector<int>(N)), preSum(20, vector<int>(N));vector<int> vpar(N, -1);function<void(int, int)> DFS = [&](int cur, int par) {vpar[cur] = par;for (int i = 0; i < 20; i++){cnt[i][cur] = (i == c[cur] - 1);preSum[i][cur] = cnt[i][cur];if (-1 != par) {preSum[i][cur] += preSum[i][par];}}for (const auto& next : neiBo[cur]) {if (next == par) { continue; }DFS(next, cur);}};DFS(0, -1);auto leves = CBFSLeve::Leve(neiBo, { 0 });C2Parents p2(vpar, leves);vector<int> ans;for (auto [u, v] : que) {u--, v--;const int g = p2.GetPublicParent(u, v);int cur = 0;for (int i = 0; i < 20; i++) {cur += (preSum[i][u] + preSum[i][v] - 2 * preSum[i][g] + cnt[i][g] > 0);}ans.emplace_back(cur);}return ans;}
};int main() {
#ifdef _DEBUGfreopen("a.in", "r", stdin);
#endif // DEBUG	ios::sync_with_stdio(0); cin.tie(nullptr);//CInBuff<> in; COutBuff<10'000'000> ob;int N, Q;cin >> N >> Q;auto c = Read<int>(N);auto edge = Read<pair<int, int>>(N - 1);auto que = Read<pair<int, int>>(Q);
#ifdef _DEBUG	printf("N=%d", N);Out(c, ",c=");Out(que, ",que=");Out(edge, ",edge=");//Out(edge2, ",edge2=");//Out(rr, ",rr=");//Out(ab, ",ab=");//Out(par, "par=");//Out(que, "que=");//Out(B, "B=");
#endif // DEBUG	Solution slu;auto res = slu.Ans(N,c,edge,que);for (const auto& i : res){cout << i << "\n";}return 0;
};

單元測試

int N;vector<int> c;vector<pair<int, int>> edge, que;TEST_METHOD(TestMethod01){N = 4, c = { 1,2,3,1 }, que = { {4,3},{1,4} }, edge = { {1,2},{1,3},{2,4} };auto res = Solution().Ans(N, c, edge, que);AssertEx({ 3,2 }, res);}

擴展閱讀

我想對大家說的話
工作中遇到的問題,可以按類別查閱鄙人的算法文章,請點擊《算法與數據匯總》。
學習算法:按章節學習《喜缺全書算法冊》,大量的題目和測試用例,打包下載。重視操作
有效學習:明確的目標 及時的反饋 拉伸區(難度合適) 專注
聞缺陷則喜(喜缺)是一個美好的愿望,早發現問題,早修改問題,給老板節約錢。
子墨子言之:事無終始,無務多業。也就是我們常說的專業的人做專業的事。
如果程序是一條龍,那算法就是他的是睛
失敗+反思=成功 成功+反思=成功

視頻課程

先學簡單的課程,請移步CSDN學院,聽白銀講師(也就是鄙人)的講解。
https://edu.csdn.net/course/detail/38771
如何你想快速形成戰斗了,為老板分憂,請學習C#入職培訓、C++入職培訓等課程
https://edu.csdn.net/lecturer/6176

測試環境

操作系統:win7 開發環境: VS2019 C++17
或者 操作系統:win10 開發環境: VS2022 C++17
如無特殊說明,本算法用**C++**實現。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/915328.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/915328.shtml
英文地址,請注明出處:http://en.pswp.cn/news/915328.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

PDF發票批量打印工具哪個好?高效打印發票的實用工具推薦

開小超市這幾年&#xff0c;每月要打幾十張進貨發票做賬&#xff0c;以前打印時總犯愁&#xff1a;有的發票 PDF 太大&#xff0c;打出來字小得看不清&#xff1b;有的又太窄&#xff0c;白白浪費半張紙。試過手動調整&#xff0c;每張都要改縮放比例&#xff0c;累不說&#x…

4G模塊 A7680通過MQTT協議連接到華為云

命令說明 基礎AT指令 ATi顯示產品的標志信息 ATCIMI查詢IMSI ATCICCID從SIM卡讀取ICCID ATCGSN查詢產品序列號 ATCPIN查詢卡狀態 ATCSQ查詢信號強度 ATCGATT查詢當前PS域狀態 ATCREG查詢GPRS注冊狀態 ATCEREG查詢4G注冊狀態 ATCGPADDR查詢PDP地址 ATCMGF選擇短信格式 ATCMGS發…

大模型詞表設計與作用解析

幾乎所有大型語言模型&#xff08;LLM&#xff09;都有自己獨立的詞表&#xff08;Vocabulary&#xff09;。這是模型設計和訓練過程中的核心組件之一。以下是關于詞表的關鍵點&#xff1a; 1. 詞表的作用 分詞基礎&#xff1a;詞表定義了模型如何將輸入文本拆分成基本單元&…

(一)Eshop(異常處理中間件/grpc)

文章目錄項目地址一、異常處理1.1 自定異常1.2 自定義異常處理中間件1.3 注冊中間件二、grpc服務2.1 創建protos1. 打折的protos2. 設置grpc server3. program配置服務4. docker-compose2.2 CRUD1. 查詢2.3 測試1. 發起查詢請求三、grpc服務消費3.1 創建client1. 添加服務2. 選…

BLIP、InternVL Series(下)

目錄 一、InternVL1.5 1、改進 二、InternVL2 1、漸進式擴展 2、多模態擴展 三、InternVL2.5 1、方法 2、數據優化 四、InternVL3 2、方法 3、訓練后處理 4、測試時擴展 五、BLIP-3o 一、InternVL1.5 1、改進 InternVL1.5在InternVL基礎上&#xff0c;優化了QLLa…

【數據結構】二維差分數組

題目鏈接 【模板】二維差分_牛客題霸_牛客網 牛客網 - 找工作神器|筆試題庫|面試經驗|實習招聘內推&#xff0c;求職就業一站解決_牛客網 描述 給定一個 nmnm 的整數矩陣 bb&#xff0c;矩陣的下標從 11 開始記作 bi,jbi,j?。現在需要支持 qq 次操作&#xff0c;第 tt 次…

【JDK內置工具】常用工具和實戰指令

作者&#xff1a;唐叔在學習 專欄&#xff1a;唐叔的Java實踐 關鍵詞: #JDK工具 #Java性能調優 #JVM調優 #內存泄漏排查 #線程死鎖分析 #Java開發工具 #線上問題排查 #Java診斷工具 Hello&#xff0c;大家好&#xff0c;我是愛學習的唐叔。作為Java開發者&#xff0c;JDK內置工…

一站式PDF轉Markdown解決方案PDF3MD

簡介 什么是 PDF3MD &#xff1f; PDF3MD 是一個現代化、用戶友好的網絡應用程序&#xff0c;旨在將 PDF 文檔轉換為干凈、格式化的 Markdown 文本。它提供了高效的轉換工具&#xff0c;支持多種文件格式之間的轉換。 主要特點 PDF 轉 Markdown&#xff1a;能夠將 PDF 文檔轉…

RocketMQ學習系列之——MQ入門概念

一、什么是MQMQ&#xff08;Message Queue&#xff0c;消息隊列&#xff09;是一種能夠實現跨進程消息傳輸&#xff0c;并且消息緩存符合隊列特性的組件。二、MQ的作用異步&#xff1a;消息發送方無需等待消息接收方收到消息&#xff0c;發送方將消息成功發送到 MQ 之后即可無阻…

血條識別功能實現及原理

從零開始學Python圖像處理 - 血條識別 從實際問題中能快速的學習特定技能&#xff0c;通過完成一個能自動刷怪的工具&#xff0c;達成快速學習python圖像處理和識別。 自動刷怪需要先識別怪物&#xff0c;在游戲中怪物類型很多&#xff0c;同時在移動中形態會一直發生變化&…

網絡地址和主機地址之間進行轉換的類

#pragma once #include "Common.hpp" // 網絡地址和主機地址之間進行轉換的類class InetAddr { public:InetAddr(){}InetAddr(struct sockaddr_in &addr) : _addr(addr){// 網絡轉主機_port ntohs(_addr.sin_port); // 從網絡中拿到的&#xff01;網絡序列// _i…

《Python 項目 CI/CD 實戰指南:從零構建自動化部署流水線》

??《Python 項目 CI/CD 實戰指南:從零構建自動化部署流水線》 一、引言:為什么 Python 項目需要 CI/CD? 在現代軟件開發中,CI/CD(持續集成 / 持續部署)已成為不可或缺的工程實踐。它不僅提升了開發效率,還顯著降低了部署風險。對于 Python 項目而言,CI/CD 的價值尤…

AJAX 技術

AJAX全稱是 Asynchronous JavaScript and XML ( 異步的JavaScript 和 XML )&#xff0c;使用該技術后&#xff0c;可以實現不刷新整個網頁&#xff0c;與服務器進行異步通信并更新部分網頁。一&#xff09;為什么需要AJAX?傳統網頁在與服務器通信時&#xff0c;需要刷新整個頁…

Python爬蟲實戰:研究NLTK庫相關技術

1. 引言 1.1 研究背景與意義 隨著互聯網的快速發展,網絡新聞已成為人們獲取信息的主要來源之一。每天產生的海量新聞文本蘊含著豐富的信息和知識,但也給信息獲取和分析帶來了挑戰。如何從大量非結構化的新聞文本中自動提取有價值的信息,識別熱點話題和趨勢,成為當前自然語…

ARM 學習筆記(二)

參考文獻&#xff1a;《ARM ArchitectureReference Manual ARMv7-A and ARMv7-R edition》1、MMU 1.1 背景早期的內存是比較小的&#xff0c;一般是幾十k&#xff0c;不過相應的程序也是比較小的&#xff0c;這時程序可以直接加載到內存中運行。后來為了支持多個程序的并行&…

Github 貪吃蛇 主頁設置

自動化腳本頂部元信息觸發條件&#xff08;on:&#xff09;作業&#xff08;jobs:&#xff09;步驟&#xff08;steps:&#xff09;1. 生成 SVG2. 推送到 output 分支Commit & Push在 README 里引用參考&#xff1a;https://github.com/Platane/Platane/tree/master 首先寫…

關于Spring RestTemplate

? 一、概述RestTemplate 是 Spring Framework 提供的一個同步 HTTP 客戶端工具&#xff0c;用于簡化與 RESTful API 的交互。它封裝了底層 HTTP 通信細節&#xff0c;提供了統一的 API 來發送各種 HTTP 請求&#xff08;GET、POST、PUT、DELETE 等&#xff09;&#xff0c;并自…

異步解決一切問題 |消息隊列 |減少嵌套 |hadoop |rabbitmq |postsql

設計準則“為什么要考慮這個問題”The forward logic is only about 10% of your code, everything else is 90%.主流邏輯 10%保障擴容和穩健的代碼設計90%同步代碼就是綁在一個繩上的螞蚱異步就是實現了解耦這個異步或許有點類似于--一些分布式數據的處理 設計如何實現的呢?…

Spring AI 項目實戰(十八):Spring Boot + AI + Vue3 + OSS + DashScope 實現高效語音識別系統(附完整源碼)

系列文章 序號 文章名稱 1 Spring AI 項目實戰(一):Spring AI 核心模塊入門 2 Spring AI 項目實戰(二):Spring Boot + AI + DeepSeek 深度實戰(附完整源碼) 3 Spring AI 項目實戰(三):Spring Boot + AI + DeepSeek 打造智能客服系統(附完整源碼) 4

指針數組和數組指針的應用案例

1. 指針數組應用&#xff1a;查找最長字符串用指針數組存儲若干字符串&#xff0c;編寫函數找出其中最長的字符串&#xff08;若有多個&#xff0c;返回第一個&#xff09;。#include <stdio.h> #include <string.h>// 函數原型&#xff1a;找出最長字符串 const c…