首頁 web前端 html教學 Codeforces Round #277.5 (Div. 2) D??Unbearable Controversy of Being_html/css_WEB-ITnose

Codeforces Round #277.5 (Div. 2) D??Unbearable Controversy of Being_html/css_WEB-ITnose

Jun 24, 2016 am 11:53 AM

D. Unbearable Controversy of Being

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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!

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:

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.

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.

When rhombi are compared, the order of intersections b and d doesn't matter.

Input

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.

It is not guaranteed that you can get from any intersection to any other one.

Output

Print the required number of "damn rhombi".

Sample test(s)

Input

5 41 22 31 44 3

Output

Input

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

Output

12

水题,只要计算出每个点走两步以后到达第三个点的所有走法,然后C(2, n)


#include <map>#include <set>#include <list>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int N = 3010;const int M = 30010;struct node{	int next;	int to;}edge[M];int head[N];int tot;int num[N][N];void addedge(int from, int to){	edge[tot].to = to;	edge[tot].next = head[from];	head[from] = tot++;}int main(){	int n, m;	while (~scanf("%d%d", &n, &m))	{		int u, v, w;		memset (head, -1, sizeof(head));		memset (num, 0, sizeof(num));		tot = 0;		for (int i = 1; i   <br>  <br>  <p></p> </algorithm></iostream></cstring></cstdio></cmath></vector></stack></queue></list></set></map>
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

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

熱門話題

Laravel 教程
1604
29
PHP教程
1510
276
'`vs.` `在html中 '`vs.` `在html中 Jul 19, 2025 am 12:41 AM

是塊級元素,用於劃分大塊內容區域;是內聯元素,適合包裹小段文字或內容片段。具體區別如下:1.獨占一行,可設置寬高、內外邊距,常用於佈局結構如頭部、側邊欄等;2.不換行,僅佔據內容寬度,用於局部樣式控制如變色、加粗等;3.使用場景上,適用於整體區域的排版與結構組織,而用於不影響整體佈局的小範圍樣式調整;4.嵌套時,可包含任何元素,而內部不應嵌套塊級元素。

使用HTML`鏈接rel =' preload”```'' 使用HTML`鏈接rel =' preload”```'' Jul 19, 2025 am 12:54 AM

linkrel="preload"是一種優化頁面加載性能的技術,用於提前加載關鍵資源。其核心用途在於優先加載對首屏渲染至關重要的資源,如字體、關鍵CSS/JS和首屏圖片。使用時需注意:1.正確設置as屬性以指定資源類型;2.避免濫用,防止帶寬佔用過高;3.確保資源會被實際使用,否則造成請求浪費;4.對跨域資源添加crossorigin屬性。錯誤寫法如缺少as屬性會導致預加載無效。合理使用可提升頁面加載效率,反之則可能適得其反。

初學者的基本HTML標籤 初學者的基本HTML標籤 Jul 27, 2025 am 03:45 AM

要快速入門HTML,只需掌握幾個基礎標籤即可搭建網頁骨架。 1.頁面結構必備、和,其中是根元素,包含元信息,是內容展示區域。 2.標題使用到,級別越高數字越小,正文用標籤分段,避免跳級使用。 3.鏈接使用標籤並配合href屬性,圖片使用標籤並包含src和alt屬性。 4.列表分為無序列表和有序列表,每個條目用表示且必須嵌套在列表中。 5.初學者不必強記所有標籤,邊寫邊查更高效,掌握結構、文本、鏈接、圖片和列表即可製作基礎網頁。

影子dom概念和HTML集成 影子dom概念和HTML集成 Jul 24, 2025 am 01:39 AM

ShadowDOM是Web組件技術中用於創建隔離DOM子樹的技術。 1.它允許在普通HTML元素上掛載獨立的DOM結構,擁有自己的樣式和行為,不與主文檔互相影響;2.通過JavaScript創建,例如使用attachShadow方法並設置mode為open;3.結合HTML使用時具備結構清晰、樣式隔離和內容投影(slot)三大特點;4.注意事項包括調試複雜、樣式作用域控制、性能開銷及框架兼容性問題。總之,ShadowDOM提供了原生封裝能力,適用於構建可複用且不污染全局的UI組件。

您可以在另一個標籤中放置一個標籤嗎? 您可以在另一個標籤中放置一個標籤嗎? Jul 27, 2025 am 04:15 AM

❌Youcannotnesttagsinsideanothertagbecauseit’sinvalidHTML;browsersautomaticallyclosethefirstbeforeopeningthenext,resultinginseparateparagraphs.✅Instead,useinlineelementslike,,orforstylingwithinaparagraph,orblockcontainerslikeortogroupmultipleparagraph

使用html`下載屬性的鏈接屬性 使用html`下載屬性的鏈接屬性 Jul 17, 2025 am 03:57 AM

TheHTMLdownloadattributeallowsuserstodownloadfilesdirectlyfromalinkbyusingthetag.Toimplementit,adddownloadtotheanchortag,suchasDownloadPDF,orspecifyacustomfilenamelikeDownloadasmy-document.pdf.1.Itworksbestwithsame-originURLsandcommonfiletypeslikePDF

html'樣式”標籤:內聯與內部CSS html'樣式”標籤:內聯與內部CSS Jul 26, 2025 am 07:23 AM

樣式放置方式需根據場景選擇。 1.Inline適合單元素臨時修改或JS動態控制,如按鈕顏色隨操作變化;2.內部CSS適合頁面少、結構簡單項目,便於集中管理樣式,如登錄頁基礎樣式設置;3.優先考慮復用性、維護性及性能,大項目拆分外鏈CSS文件更優。

如何在HTML中嵌入YouTube視頻 如何在HTML中嵌入YouTube視頻 Jul 16, 2025 am 04:43 AM

要在網頁中嵌入YouTube視頻,可直接複製YouTube提供的嵌入代碼並粘貼到HTML頁面中;1.打開目標視頻頁面並確認正確視頻鏈接;2.點擊“分享”→“嵌入”,複製生成的iframe代碼;3.或手動創建iframe標籤並設置src為https://www.youtube.com/embed/視頻ID;4.推薦使用響應式寬度和添加allowfullscreen屬性;5.進階建議包括使用容器實現16:9比例、延遲加載以提升性能及注意隱私政策提示。

See all articles