mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-05-10 08:10:27 +08:00
Add Codeforces Code
This commit is contained in:
parent
8dbc0861b2
commit
da903edacd
25
CodeForces/Arranging Cats.cpp
Normal file
25
CodeForces/Arranging Cats.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<algorithm>
|
||||
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;
|
||||
}
|
19
CodeForces/Forming Triangles.cpp
Normal file
19
CodeForces/Forming Triangles.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include<iostream>
|
||||
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;
|
||||
}
|
1
CodeForces/README.md
Executable file
1
CodeForces/README.md
Executable file
@ -0,0 +1 @@
|
||||
# CF题不多,后面会做的!!!!!
|
Loading…
x
Reference in New Issue
Block a user