还是只会4道。。sad。。。
A:SwapSort
用一个数组存储排好序之后。然后从头开始依次将需要交换的与本来应该在这个位置的交换,最多交换n-1次。
代码如下;
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;int a[4000], b[4000], c[4000], d[4000];int main(){ int i, j, n, pos, cnt; while(scanf("%d",&n)!=EOF) { cnt=0; for(i=0;i<n scanf b sort for if pos="j;" break swap c printf return> <br> B: BerSU Ball <p></p> <p>二分图最大匹配裸题。</p> <p>代码如下:</p> <p></p> <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;int link[200], vis[200], n, m, a[200], b[200];int head[200], cnt;struct node{ int u, v, next;}edge[100000];void add(int u, int v){ edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}int dfs(int u){ int i; for(i=head[u];i!=-1;i=edge[i].next) { int v=edge[i].v; if(!vis[v]) { vis[v]=1; if(link[v]==-1||dfs(link[v])) { link[v]=u; return 1; } } } return 0;}void hungary(){ int i, ans=0; memset(link,-1,sizeof(link)); for(i=0;i<n memset if ans printf main int i j while for scanf cnt="0;" add hungary return> <br> C: Given Length and Sum of Digits... <p></p> <p>贪心水题。</p> <p>按照顺序依次填充。</p> <p>代码如下:</p> <p></p> <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const int INF=0x3f3f3f3f;int a[1000], b[1000];int main(){ int m, s, i, j, x; while(scanf("%d%d",&m,&s)!=EOF) { if(m*9<s printf continue if else x="s-1;" for i>=2; i--) { if(x>=9) { a[i]=9; x-=9; } else if(x>=0&&x=9) { b[i]=9; x-=9; } else if(x>=0&&x <br> D: Unbearable Controversy of Being </s><p></p> <p>枚举起点,分别进行BFS找到距离为2的点,然后记录到达这个点的次数,若次数大于2,说明存在,根据组合数来求解。</p> <p>代码如下:</p> <p></p> <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64LL vis[4000], ans;int head[4000], cnt, n;struct node{ int u, v, next;}edge[50000];void add(int u,int v){ edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}void bfs(int x){ int i; queue<int>q; for(i=head[x];i!=-1;i=edge[i].next) { q.push(edge[i].v); } while(!q.empty()) { int u=q.front(); q.pop(); for(i=head[u];i!=-1;i=edge[i].next) { int v=edge[i].v; if(v!=x) vis[v]++; } } for(i=1;i=2) ans+=vis[i]*(vis[i]-1)/2; }}int main(){ int m, i, j, u, v; scanf("%d%d",&n,&m); ans=0; memset(head,-1,sizeof(head)); cnt=0; while(m--) { scanf("%d%d",&u,&v); add(u,v); } for(i=1;i <br> <br> <p></p> </int></algorithm></set></map></queue></ctype.h></math.h></stdlib.h></cstring></string></cstdio></iostream>

公眾號網頁更新緩存,這玩意兒,說簡單也簡單,說複雜也夠你喝一壺的。你辛辛苦苦更新了公眾號文章,結果用戶打開還是老版本,這滋味,誰受得了?這篇文章,咱就來扒一扒這背後的彎彎繞繞,以及如何優雅地解決這個問題。讀完之後,你就能輕鬆應對各種緩存難題,讓你的用戶始終體驗到最新鮮的內容。先說點基礎的。網頁緩存,說白了就是瀏覽器或者服務器為了提高訪問速度,把一些靜態資源(比如圖片、CSS、JS)或者頁面內容存儲起來。下次訪問時,直接從緩存裡取,不用再重新下載,速度自然快。但這玩意兒,也是個雙刃劍。新版本上線,

本文討論了使用HTML5表單驗證屬性,例如必需的,圖案,最小,最大和長度限制,以直接在瀏覽器中驗證用戶輸入。

本文展示了使用CSS為網頁中添加有效的PNG邊框。 它認為,與JavaScript或庫相比,CSS提供了出色的性能,詳細介紹瞭如何調整邊界寬度,樣式和顏色以獲得微妙或突出的效果

本文討論了html&lt; datalist&gt;元素,通過提供自動完整建議,改善用戶體驗並減少錯誤來增強表格。Character計數:159

本文解釋了HTML5&lt; time&gt;語義日期/時間表示的元素。 它強調了DateTime屬性對機器可讀性(ISO 8601格式)的重要性,並在人類可讀文本旁邊,增強Accessibilit

本文討論了HTML&lt; Progress&gt;元素,其目的,樣式和與&lt; meter&gt;元素。主要重點是使用&lt; progress&gt;為了完成任務和LT;儀表&gt;對於stati

本文討論了HTML&lt; meter&gt;元素,用於在一個範圍內顯示標量或分數值及其在Web開發中的常見應用。它區分了&lt; meter&gt;從&lt; progress&gt;和前


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版