当前位置:网站首页>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 !
边栏推荐
- C # implements a queue in which everything can be sorted
- Codeforces Round #803 (Div. 2)(A-D)
- 2022 electrician (intermediate) examination question bank and electrician (intermediate) examination questions and analysis
- 团体程序设计天梯赛-练习集 L2-002 链表去重
- manjaro安装微信
- Flutter 集成 amap_flutter_location
- What does range mean in PHP
- 运动【跑步 01】一个程序员的半马挑战:跑前准备+跑中调整+跑后恢复(经验分享)
- Snipaste convenient screenshot software, which can be copied on the screen
- 埃氏筛+欧拉筛+区间筛
猜你喜欢
1. Getting started with QT
【性能測試】一文讀懂Jmeter
How to play dapr without kubernetes?
ES6 summary
Manjaro install wechat
The second session of the question swiping and punching activity -- solving the switching problem with recursion as the background (I)
Display Chinese characters according to numbers
[CV] Wu Enda machine learning course notes | Chapter 9
Codeforces Global Round 21(A-E)
微服务入门:Gateway网关
随机推荐
Unity write word
ArcGIS应用(二十二)Arcmap加载激光雷达las格式数据
Azure ad domain service (II) configure azure file share disk sharing for machines in the domain service
一文了解數據异常值檢測方法
awk从入门到入土(4)用户自定义变量
Convert datetime string to datetime - C in the original time zone
学习Nuxt.js
Openfeign service interface call
Conversion of yolov5 XML dataset to VOC dataset
Redis sentinel mechanism
[untitled] 2022 polymerization process analysis and polymerization process simulation examination
Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
Basic operations of databases and tables ----- view data tables
System disk expansion in virtual machine
Figure guessing game
1. Qt入门
Comparison between sentinel and hystrix
团体程序设计天梯赛-练习集 L1-006 连续因子
Technology sharing | MySQL parallel DDL
High order phase difference such as smear caused by myopic surgery