当前位置:网站首页>Educational Codeforces Round 115 (Rated for Div. 2)
Educational Codeforces Round 115 (Rated for Div. 2)
2022-07-04 08:38:00 【ccsu_ yuyuzi】
Catalog
A. Computer Game
Problem - A - Codeforceshttps://codeforces.com/contest/1598/problem/A The question : There is one 2 That's ok n Column map , We need to (1,1) Go to the (2,n). Can only walk to meet |x1−x2|≤1 && |y1−y2|≤1(1 For the original position ,2 For the new location ).
Ideas , As long as there is not a column 1 You can walk to .
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<unordered_map>
#define int long long
using namespace std;
const int N =5e5+10,mod=998244353;
void solve()
{
string s1,s2;
int n;
cin>>n;
cin>>s1>>s2;
for(int i=0;i<n;i++)
{
if(s1[i]==s2[i]&&s1[i]=='1')
{
cout<<"NO\n";
return ;
}
}
cout<<"YES\n";
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
B. Groups
Problem - B - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1598/problem/B The question : Yes n A student , Divide into two equal groups (n%2==0), Ensure that the two groups can have classes in different two days . Given a matrix ,1 It means they can have class today . Ask if you can tell .
Ideas : The train of thought is hard to say , Look directly at the code :
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<unordered_map>
using namespace std;
const int N =5e5+10,mod=998244353;
int a[1024][6];
void solve()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=5;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=5;i++)
{
for(int j=i+1;j<=5;j++)
{
int cnt1=0,cnt2=0,f=0;
for(int k=1;k<=n;k++)
{
if((a[k][i]|a[k][j])==0)
{
f=1;
break;
}
if(a[k][i]==1)
cnt1++;
if(a[k][j]==1)
cnt2++;
}
if(f==1)
continue;
if(cnt1>=n/2&&cnt2>=n/2)
{
printf("YES\n");
return ;
}
}
}
printf("NO\n");
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
C. Delete Two Elements
Problem - C - Codeforceshttps://codeforces.com/contest/1598/problem/C The question : You from n Delete two numbers from the array of numbers , Keep the average constant , How many deletion methods are there .
We only need to traverse while using map Record the number of times this number appears , Use the average obtained before *2 Subtract the number currently traversed , If map This result exists in existence , It means that you can delete , Just combine it directly with what appeared before .
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<unordered_map>
#define int long long
using namespace std;
map<double,int>ma;
double a[200005];
void solve()
{
ma.clear();
int n,ans=0;
double sum=0;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
scanf("%lf",&a[i]),sum+=a[i];
double avg=(double)sum/n;
for(int i=1;i<=n;i++)
{
double temp=avg*2-a[i];
if(ma.count(temp))
ans+=(ma[temp]);
ma[a[i]]++;
}
printf("%lld\n",ans);
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
D. Training Session
Problem - D - Codeforceshttps://codeforces.com/contest/1598/problem/D
The question : Here you are. n A mission , All contain one a Value and a b value . Choose three tasks , These three tasks should meet one of the two conditions :1.a Be different from each other .2.b Be different from each other . Ask how many options there are .
Ideas : If you ask directly according to the conditions , It's too hard , Stuck me for a long time , You might as well use the idea of tolerance and exclusion , Calculate all the three methods , Then subtract the illegal choice . The illegal choice must be as follows
a b
a y
x b (x,y It can be any value )
So we can do the following for each task a,b Then go to choose one that contains a Task and one containing b The task of . You can drive two map For recording , Calculate directly in traversal :
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<unordered_map>
#define int long long
using namespace std;
map<int,int>ma,ma1;
int a[200005];
int b[200005];
void solve()
{
ma.clear();
ma1.clear();
int n,ans;
scanf("%lld",&n);
ans=n*(n-1)*(n-2)/2/3;
for(int i=1;i<=n;i++)
{
scanf("%lld%lld",&a[i],&b[i]);
ma[a[i]]++;
ma1[b[i]]++;
}
for(int i=1;i<=n;i++)
{
ans-=(ma[a[i]]-1)*(ma1[b[i]]-1);
}
printf("%lld\n",ans);
return;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
Fight hard !
边栏推荐
- 09 softmax regression + loss function
- User login function: simple but difficult
- Redis sentinel mechanism
- 团体程序设计天梯赛-练习集 L1-006 连续因子
- [untitled] 2022 polymerization process analysis and polymerization process simulation examination
- DM8 command line installation and database creation
- L1 regularization and L2 regularization
- Flutter integrated amap_ flutter_ location
- 2022 examination questions for safety managers of metal and nonmetal mines (underground mines) and examination papers for safety managers of metal and nonmetal mines (underground mines)
- DM8 uses different databases to archive and recover after multiple failures
猜你喜欢
Turn: excellent managers focus not on mistakes, but on advantages
Four essential material websites for we media people to help you easily create popular models
没有Kubernetes怎么玩Dapr?
What sparks can applet container technology collide with IOT
How to solve the problem that computers often flash
1. Kalman filter - the best linear filter
Take you to master the formatter of visual studio code
Azure ad domain service (II) configure azure file share disk sharing for machines in the domain service
Fault analysis | MySQL: unique key constraint failure
根据数字显示中文汉字
随机推荐
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
Technology sharing | MySQL parallel DDL
What if the wireless network connection of the laptop is unavailable
[test de performance] lire jmeter
Internal learning
awk从入门到入土(12)awk也可以写脚本,替代shell
ArcGIS应用(二十二)Arcmap加载激光雷达las格式数据
Leetcode 23. Merge K ascending linked lists
How to solve the problem that computers often flash
manjaro安装微信
Educational Codeforces Round 115 (Rated for Div. 2)
L1 regularization and L2 regularization
The right way to capture assertion failures in NUnit - C #
Example analysis of C # read / write lock
How to re enable local connection when the network of laptop is disabled
awk从入土到入门(10)awk内置函数
ES6 summary
没有Kubernetes怎么玩Dapr?
Take you to master the formatter of visual studio code
Bishi blog (13) -- oral arithmetic test app