当前位置:网站首页>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 - Codeforces
https://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 community
https://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 - Codeforces
https://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 - Codeforces
https://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 !
边栏推荐
- DM database password policy and login restriction settings
- What does range mean in PHP
- [attack and defense world | WP] cat
- 转:优秀的管理者,关注的不是错误,而是优势
- Show server status on Web page (on or off) - PHP
- Use preg_ Match extracts the string into the array between: & | people PHP
- Cancel ctrl+alt+delete when starting up
- How to solve the problem of computer jam and slow down
- 1. Getting started with QT
- 没有Kubernetes怎么玩Dapr?
猜你喜欢

User login function: simple but difficult
![[CV] Wu Enda machine learning course notes | Chapter 9](/img/de/41244904c8853b8bb694e05f430156.jpg)
[CV] Wu Enda machine learning course notes | Chapter 9

L1 regularization and L2 regularization

The basic syntax of mermaid in typera

std::is_ union,std::is_ class,std::integral_ constant

Démarrage des microservices: passerelle

没有Kubernetes怎么玩Dapr?

Question 49: how to quickly determine the impact of IO latency on MySQL performance

Four essential material websites for we media people to help you easily create popular models

Snipaste convenient screenshot software, which can be copied on the screen
随机推荐
Need help resetting PHP counters - PHP
Cancel ctrl+alt+delete when starting up
Leetcode 23. Merge K ascending linked lists
What if I forget the router password
Codeforces Global Round 21(A-E)
Newh3c - network address translation (NAT)
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
【性能測試】一文讀懂Jmeter
1. Getting started with QT
微服务入门:Gateway网关
Use preg_ Match extracts the string into the array between: & | people PHP
How to use C language code to realize the addition and subtraction of complex numbers and output structure
[untitled] 2022 polymerization process analysis and polymerization process simulation examination
A method for detecting outliers of data
DM8 database recovery based on point in time
Put a lantern on the website during the Lantern Festival
snipaste 方便的截图软件,可以复制在屏幕上
Example analysis of C # read / write lock
Leetcode 146. LRU cache
User login function: simple but difficult