From da903edacdfbf0a20fbad689534604192bd51206 Mon Sep 17 00:00:00 2001 From: Fengyi Chen Date: Thu, 15 Feb 2024 22:52:21 +0800 Subject: [PATCH] Add Codeforces Code --- .DS_Store | Bin 6148 -> 6148 bytes CodeForces/Arranging Cats.cpp | 25 +++++++++++++++++++++++++ CodeForces/Forming Triangles.cpp | 19 +++++++++++++++++++ CodeForces/README.md | 1 + 4 files changed, 45 insertions(+) create mode 100644 CodeForces/Arranging Cats.cpp create mode 100644 CodeForces/Forming Triangles.cpp create mode 100755 CodeForces/README.md diff --git a/.DS_Store b/.DS_Store index b696e34020a5645847c5f9418bc616d5365b0582..0a4696fa31edce52fea7da7776ed90f4d96839b8 100644 GIT binary patch delta 519 zcmZoMXfc=|#>B!ku~2NHo}wrh0|Nsi1A_nqgBwFWLlHwVLn=e@=7)^Snd?DPTnx@Y z;S``Cl5|peaY0f}eiBfAM^ZsfW^svu!8JxEW)@a9c6Ls7ZuZ#VjQsN8lEjkIVyDES zXb>+XKR+i4#!gHM%SstrKXXoVR<#z!c2Ly~j zzkvZSl!j5=Kn7ON<)j-1C+FuDFx118;!v2I@8SXt1&+(lCjHahf7B6|p}F}fM5`^x zfH*)0VLx`4mIW8(<>cq31JyB3c3@Q5Y{00`w3(fQp92`Zz$pCAJegm_QUDkN;6MNp NOdumSM~JLp1^~d#d8+^b delta 98 zcmZoMXfc=|#>B`mu~2NHo}wrV0|Nsi1A_nqgFk~8gTlnKacwdD6APC!vP@QBQ`vlj tRiA0I0tY+G#D;~N**W+*fI2q|a(ri=%r9aI)CAVd1f^LvM~JLp1^_l>6a@eP diff --git a/CodeForces/Arranging Cats.cpp b/CodeForces/Arranging Cats.cpp new file mode 100644 index 0000000..1f0d15e --- /dev/null +++ b/CodeForces/Arranging Cats.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +using namespace std; + +int t; +int main() +{ + cin >> t; + while(t -- ) + { + int n; + cin >> n; + string s1, s2; + cin >> s1 >> s2; + int x = 0, y = 0; + for(int i = 0; i < n; i ++ ) + { + if(s1[i] == '1' && s2[i] == '0') x ++ ; + if(s1[i] == '0' && s2[i] == '1') y ++ ; + } + cout << max(x, y) << endl; + } + return 0; +} diff --git a/CodeForces/Forming Triangles.cpp b/CodeForces/Forming Triangles.cpp new file mode 100644 index 0000000..b363332 --- /dev/null +++ b/CodeForces/Forming Triangles.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +long long t, n, a[300005]; +long long cnt[300005], s[300005], ans; +int main(){ + ios::sync_with_stdio(0); + cin >> t; + while(t -- ){ + cin >> n; + ans = 0; + for(int i = 0; i <= n; i ++ ) cnt[i] = s[i] = 0; + for(int i = 1; i <= n; i ++ ) cin >> a[i], cnt[a[i]] ++ ; + for(int i = 0; i <= n; i ++ ) ans += cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6, s[i] = (i == 0 ? 0 : s[i - 1]) + cnt[i]; + for(int i = 1; i <= n; i ++ ) ans += cnt[i] * (cnt[i] - 1) / 2 * s[i-1]; + cout << ans << "\n"; + } + return 0; +} diff --git a/CodeForces/README.md b/CodeForces/README.md new file mode 100755 index 0000000..7a9fbd1 --- /dev/null +++ b/CodeForces/README.md @@ -0,0 +1 @@ +# CF题不多,后面会做的!!!!! \ No newline at end of file