当前位置:网站首页>Educational Codeforces Round 119 (Rated for Div. 2)
Educational Codeforces Round 119 (Rated for Div. 2)
2022-07-04 08:38:00 【ccsu_ yuyuzi】
A. Equal or Not Equal
Statistics E The number of , by 1 The output "NO".
#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 s;
cin>>s;
int cnt=0;
for(int i=0;i<s.size();i++)
{
if(s[i]=='N')
cnt++;
}
if(cnt==1)
cout<<"NO\n";
else
cout<<"YES\n";
return ;
}
signed main()
{
int t;
cin>>t;
while( t--)
solve();
return 0;
}
B. Triangles on a Rectangle
Problem - B - Codeforceshttps://codeforces.com/contest/1620/problem/B Direct enumeration , Take the maximum value :
#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;
int arr[200005];
void solve()
{
int ans=0;
int w,h,k,cheng;
cin>>w>>h;
for(int i=0;i<4;i++)
{
if(i<2)
cheng=h;
else
cheng=w;
cin>>k;
for(int j=1;j<=k;j++)
cin>>arr[j];
sort(arr+1,arr+1+k);
ans=max(ans,abs(arr[1]-arr[k])*cheng);
}
cout<<ans<<"\n";
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
C. BA-String
Problem - C - Codeforceshttps://codeforces.com/contest/1620/problem/C The question : Here are three numbers n,k,x, I'll give you one that only contains a,* String Will be one of the * Replace with [ 0 , k ] individual b, Ask you the order of the dictionary in all cases x What is the small .
Ideas , We can a As a division symbol , Because no matter how it changes ,a Always there . This string can be regarded as many characters that can determine the upper limit b The substring of and dividing them only contain a The string of . By enumeration , Will find , When divided a Substring ( Let's call him to split the string ) The variable length on the right only contains b The string of ( Let's call him to change the string ) In substring b The number of is filled , When traversing down according to the dictionary order , You need to add a before this split string b, Only then can we continue from one b Began to increase . This is very similar to our radix , But the base of each digit of this question is not necessarily the same length . Then we can calculate the transformable length of each transformation string , As the number of this bitwise conversion , Order the dictionary directly from 0 Just start the hexadecimal conversion , Output the corresponding string .
#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;
void solve()
{
string s;
int n,k,x;
cin>>n>>k>>x;
cin>>s;
reverse(s.begin(),s.end());
int cnt=0;
string res="";
x--;
for(int i=0;i<s.size();i++)
{
if(s[i]=='a')
{
int num=x%(cnt*k+1);
x/=(cnt*k+1);
for(int i=0;i<num;i++)
res+='b';
res+='a';
cnt=0;
}
else
cnt++;
}
int num=x%(cnt*k+1);
for(int i=0;i<num;i++)
res+='b';
reverse(res.begin(),res.end());
cout<<res<<"\n";
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
E. Replace the Numbers
Problem - E - Codeforceshttps://codeforces.com/contest/1620/problem/E The question : Here you are. n operations , Enter one number at a time , When this number is 1 when , Insert an input number at the end of an originally empty array x, When this number is 2 When , Input x and y, Put all that is now in the array x All become y.
This problem is simulated at the beginning , Naturally t stay 23 A sample . Then look at the solution , Learned a method of merging and searching sets .
We directly put the position of the array storing the values of the same number ( Record with position ), Put it in a collection , If you want to modify it, you only need to perform the operation of merging and querying sets , Let's merge two parallel search sets , Then the root node points to a value , This value is the value of the current position . Detailed comments are in the following 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;
int fa[500005],num[500005],vis[500005];
//fa It records the parent node , So that many nodes can form a set ( Of course, their serial numbers are stored here )
//vis What is recorded is the value of a sequence number , That is, the corresponding sequence number should exist in the value in the array
//num The record is the sequence number of a value stored in the array ( The serial number of this deposit is not necessarily , As long as the number is in a set )
int find(int x)
{
if(x!=fa[x])
fa[x]=find(fa[x]);
return fa[x];
}
// Path compression and set lookup
void solve()
{
int q,op,x,y,tot=0;
scanf("%d",&q);
for(int i=1;i<=500000;i++)
fa[i]=i;
while(q--)
{
scanf("%d",&op);
if(op==1)
{
tot++;
scanf("%d",&x);
fa[tot]=tot;// Record the parent node for yourself
vis[tot]=x;// Assign a value to the parent node
if(num[x])
fa[tot]=num[x];
// If the value stored in the array x Already contains nodes ( Initialization is 0, If it is 0 It means that there is no such number in the array x)
else
num[x]=tot;
// Make sure that the number exists in the array , And take a number in the set to store , From this number, we can directly find To its parent node , It can be directly determined vis The value of the inside
}
else
{
scanf("%d%d",&x,&y);
if(num[x]&&x!=y)
{
// If present, the value is x The number of is in the array , also x,y It needs to change
if(num[y])
{
fa[num[x]]=num[y];
num[x]=0;
}
// If there is y The value of is in the array , Directly merge sets , Of course , After the merger , The value is x The collection of disappeared , Set as 0
else
{
num[y]=num[x];
vis[num[x]]=y;
num[x]=0;
}
// If it doesn't exist y The value of is in the array , Directly put the whole x The set of is transformed into y The combination of , In the x Set elimination
}
}
}
for(int i=1;i<=tot;i++)
printf("%d ",vis[find(i)]);
// Output the corresponding vis value
return ;
}
signed main()
{
solve();
return 0;
}
Fight hard
边栏推荐
- 微服務入門:Gateway網關
- Show server status on Web page (on or off) - PHP
- ArcGIS application (XXII) ArcMap loading lidar Las format data
- Moher College phpmailer remote command execution vulnerability tracing
- How to set multiple selecteditems on a list box- c#
- Go zero micro service practical series (IX. ultimate optimization of seckill performance)
- deno debugger
- How to improve your system architecture?
- Webapi interview question summary 01
- AcWing 244. Enigmatic cow (tree array + binary search)
猜你喜欢
DM8 uses different databases to archive and recover after multiple failures
A method for detecting outliers of data
Conversion of yolov5 XML dataset to VOC dataset
Wechat has new functions, and the test is started again
1. Qt入门
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
What does range mean in PHP
FOC控制
一文了解數據异常值檢測方法
[CV] Wu Enda machine learning course notes | Chapter 9
随机推荐
Developers really review CSDN question and answer function, and there are many improvements~
Unity-Text上标平方表示形式+text判断文本是否为空
yolov5 xml数据集转换为VOC数据集
Cancel ctrl+alt+delete when starting up
@Role of requestparam annotation
力扣今日题-1200. 最小绝对差
If the array values match each other, shuffle again - PHP
[Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
微服务入门:Gateway网关
[CV] Wu Enda machine learning course notes | Chapter 9
Go zero micro service practical series (IX. ultimate optimization of seckill performance)
Bishi blog (13) -- oral arithmetic test app
Codeforces Round #793 (Div. 2)(A-D)
std::is_ union,std::is_ class,std::integral_ constant
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
Moher college phpMyAdmin background file contains analysis traceability
Technology sharing | MySQL parallel DDL
[go basics] 1 - go go