搜尋
首頁web前端html教學Codeforces Round #277.5 (Div. 2)-D_html/css_WEB-ITnose

题意:求该死的菱形数目。直接枚举两端的点,平均意义每个点连接20条边,用邻接表暴力计算中间节点数目,那么中间节点任选两个与两端可组成的菱形数目有r*(r-1)/2.

代码:

#include<iostream>#include<cstdio>#include<cmath>#include<map>#include<cstring>#include<algorithm>#define rep(i,a,b) for(int i=(a);i=(b);i--)#define clr(a,x) memset(a,x,sizeof a)typedef long long LL;using namespace std;const int mod=1e9 +7;const int maxn=3005;const int maxm=30005;int first[maxn],nex[maxm],v[maxm],ecnt,g[maxn][maxn];void add_(int a,int b){    v[ecnt]=b;    nex[ecnt]=first[a];    first[a]=ecnt++;}int main(){    int n,m,x,y;    while(~scanf("%d%d",&n,&m))    {        memset(first,-1,sizeof first);ecnt=0;        memset(g,0,sizeof g);        for(int i=0;i<m scanf int ans="0;" for i="1;i<=n;i++)" j="1;j<=n;j++)" if r="0;" e="first[i];~e;e=nex[e])" printf return>  <br>  <br>  <p></p>  <p><br> </p>  <p></p>  <p class="sycode">   </p>
<p class="sycode">    </p>
<p class="sycode">     </p>
<p class="sycode">      </p>
<p class="sycode">       </p>
<p class="sycode">        </p>
<p class="sycode">         D. Unbearable Controversy of Being        </p>        <p class="sycode">         </p>
<p class="sycode">          time limit per test         </p> 1 second                <p class="sycode">         </p>
<p class="sycode">          memory limit per test         </p> 256 megabytes                <p class="sycode">         </p>
<p class="sycode">          input         </p> standard input                <p class="sycode">         </p>
<p class="sycode">          output         </p> standard output                      <p class="sycode">        </p>
<p> Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different!</p>        <p> Tomash has noticed that even simple cases of ambiguity confuse him. So, when he sees a group of four distinct intersections a, b, c and d, such that there are two paths from a to c ? one through b and the other one through d, he calls the group a "damn rhombus". Note that pairs (a,?b), (b,?c), (a,?d), (d,?c) should be directly connected by the roads. Schematically, a damn rhombus is shown on the figure below:</p>                <p> Other roads between any of the intersections don't make the rhombus any more appealing to Tomash, so the four intersections remain a "damn rhombus" for him.</p>        <p> Given that the capital of Berland has n intersections and m roads and all roads are unidirectional and are known in advance, find the number of "damn rhombi" in the city.</p>        <p> When rhombi are compared, the order of intersections b and d doesn't matter.</p>              <p class="sycode">        </p>
<p class="sycode">         Input        </p>        <p> The first line of the input contains a pair of integers n, m (1?≤?n?≤?3000,?0?≤?m?≤?30000) ? the number of intersections and roads, respectively. Next m lines list the roads, one per line. Each of the roads is given by a pair of integers ai,?bi (1?≤?ai,?bi?≤?n;ai?≠?bi) ? the number of the intersection it goes out from and the number of the intersection it leads to. Between a pair of intersections there is at most one road in each of the two directions.</p>        <p> It is not guaranteed that you can get from any intersection to any other one.</p>              <p class="sycode">        </p>
<p class="sycode">         Output        </p>        <p> Print the required number of "damn rhombi".</p>              <p class="sycode">        </p>
<p class="sycode">         Sample test(s)        </p>        <p class="sycode">         </p>
<p class="sycode">          </p>
<p class="sycode">           input          </p>          <pre style="代码" class="precsshei">5 41 22 31 44 3

output

input

4 121 21 31 42 12 32 43 13 23 44 14 24 3

output

12



陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?Mar 04, 2025 pm 12:32 PM

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

如何使用HTML5表單驗證屬性來驗證用戶輸入?如何使用HTML5表單驗證屬性來驗證用戶輸入?Mar 17, 2025 pm 12:27 PM

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

HTML5中跨瀏覽器兼容性的最佳實踐是什麼?HTML5中跨瀏覽器兼容性的最佳實踐是什麼?Mar 17, 2025 pm 12:20 PM

文章討論了確保HTML5跨瀏覽器兼容性的最佳實踐,重點是特徵檢測,進行性增強和測試方法。

如何高效地在網頁中為PNG圖片添加描邊效果?如何高效地在網頁中為PNG圖片添加描邊效果?Mar 04, 2025 pm 02:39 PM

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

&lt; datalist&gt;的目的是什麼。 元素?&lt; datalist&gt;的目的是什麼。 元素?Mar 21, 2025 pm 12:33 PM

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

&lt; meter&gt;的目的是什麼。 元素?&lt; meter&gt;的目的是什麼。 元素?Mar 21, 2025 pm 12:35 PM

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

我如何使用html5&lt; time&gt; 元素以語義表示日期和時間?我如何使用html5&lt; time&gt; 元素以語義表示日期和時間?Mar 12, 2025 pm 04:05 PM

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

&gt; gt;的目的是什麼 元素?&gt; gt;的目的是什麼 元素?Mar 21, 2025 pm 12:34 PM

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

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前By尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

DVWA

DVWA

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

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Safe Exam Browser

Safe Exam Browser

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

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境