当前位置:网站首页>2022.07.11 summer training personal qualifying (VI)
2022.07.11 summer training personal qualifying (VI)
2022-07-28 11:59:00 【Chao Tang】
2022.07.11 Summer training Individual qualifying ( 6、 ... and )
Post game introspection
It looks better than before , But it's still normal . Dynamic planning is still unskilled . Continue refueling .
I didn't sleep last night , It's over cf It's so exciting , Then I watched the mobile phone for a while, and after reading the question, I became more excited and couldn't sleep . Don't make up the question today .
Problem E
Source
Codeforces-1084C
Answer key
First think of the string as just letters a And letters b Sequence , With b Separator ,b hold a Divided into several parts , The number of each copy is different . A group b Ahead a Mandatory , Then you can choose b hinder a Any one to form the answer , In fact, it is also a combinatorial counting problem ,
Code
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int mod=1e9+7;
int n, T = 1, m;
string st;
int len,all=1,ans;
vector<int> cnta;
int qsm(int x,int y){
int res=1;
while(y){
if(y&1) res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res%mod;
}
void ready()
{
int cnt=0;
cin>>st;
len=st.size();
for(auto item:st){
if(item=='a'){
cnt++;
}
if(item=='b'){
if(cnt){
cnta.push_back(cnt);
cnt=0;
}
}
}
if(cnt) cnta.push_back(cnt);
for(auto item:cnta) all=all*(item+1)%mod;
for(auto item:cnta){
all=all*qsm(item+1,mod-2)%mod;
ans=(ans+item*all%mod)%mod;
//cout<<item<<' '<<all<<' '<<ans<<'\n';
}
cout<<ans;
}
void work()
{
}
signed main()
{
IOS;
ready();
//cin>>T;
while (T--) {
work();
}
return 0;
}
Problem F
Source
Codeforces-1163B2
Answer key
Inductive questions
Only ___-__ When there are other all the same , The number of times to add a new one is 1 Meet the requirements when .
In addition, pay attention to some special situations , For example, all are the same color or different colors .
Code
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int N=1e5+5;
int n, T = 1, m;
int col[N],cnt[N],maxn,minn;
void out(){
cout<<"col\n";
for(int i=1;i<=n;i++) cout<<col[i]<<' ';
cout<<"\ncnt\n";
for(int i=1;i<=n;i++) cout<<cnt[i]<<' ';
cout<<"\n\n";
}
void ready()
{
int ans=1,num=0;
cin>>n;
maxn=minn=1;
ffor(i,1,n){
int x;
cin>>x;
if(!col[x]) num++;
else cnt[col[x]]--;
if(cnt[col[x]]==0 && minn==col[x]) minn++;
col[x]++; cnt[col[x]]++;
maxn=max(maxn,col[x]);
minn=min(minn,col[x]);
if(cnt[maxn]==1 && minn==maxn-1)
ans=i;
if(minn==1 && cnt[minn]==1 && num==cnt[maxn]+1)
ans=i;
if(maxn==minn && (maxn == 1 || num == 1))
ans=i;
// cout<<"i="<<i<<" num="<<num<<'\n';
// cout<<"maxn="<<maxn<<' '<<" minn="<<minn<<'\n';
// out();
}
cout<<ans;
}
void work()
{
}
signed main()
{
IOS;
ready();
//cin>>T;
while (T--) {
work();
}
return 0;
}
Problem I
Source
Codeforces-1129A2
Answer key
greedy .
Each point can only take one sugar , How many points you send, how many circles you have to walk . Then the last time you send the circle must be at least . In this way, we can calculate , From this point , Then what is the shortest distance to send all the sweets .
Then enumerate from different points , Assuming that i. If you want to send j Of candy , So the path is i To j The path of +j The path to send all the sweets . about i, Enumerate all j Then take the largest , This can guarantee others j All have been delivered .
Code
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int N=5005;
int n, T = 1, m;
int dp[5005][5005];
vector<int> ve[N];
int maxn[N];
void ready()
{
cin>>n>>m;
ffor(i,1,n){
int cnt=0;
int j=i+1;
if(j>n) j=1;
while(j!=i){
cnt++;
dp[i][j]=cnt;
j++;
if(j>n) j=1;
}
}
/*ffor(i,1,n){ ffor(j,1,n) cout<<dp[i][j]<<' '; cout<<'\n'; }*/
ffor(i,1,m){
int a,b;
cin>>a>>b;
ve[a].push_back(b);
}
}
void work()
{
ffor(i,1,n){
int minn=INF,cnt=0;
for(auto v:ve[i]){
minn=min(minn,dp[i][v]);
cnt++;
}
if(minn==INF) minn=0,cnt=1;
maxn[i]=(cnt-1)*n+minn;
}
ffor(i,1,n){
int ans=0;
ffor(j,1,n){
//if(i==j) continue;
if(maxn[j])
ans=max(ans,dp[i][j]+maxn[j]);
}
cout<<ans<<' ';
}
}
signed main()
{
IOS;
ready();
//cin>>T;
while (T--) {
work();
}
return 0;
}
边栏推荐
- Untiy controls the playback speed of animation
- [geek challenge 2019] babysql-1 | SQL injection
- R language ggplot2 visualization: ggdensity function of ggpubr package visualizes density graph and uses stat_ overlay_ normal_ Density function superimposes positive distribution curve, custom config
- Hcip (condition matching and OSPF packet related knowledge)
- 从零开始Blazor Server(2)--整合数据库
- I want to ask you guys, if there is a master-slave switch when CDC collects mysql, is there any solution
- Flash point list of cross platform efficiency software
- R language ggplot2 visualization: use the ggdotplot function of ggpubr package to visualize the grouped dot plot, set the palette parameter, and set the color of data points in different grouped dot p
- R language ggplot2 visualization: use the ggdotplot function of ggpubr package to visualize dot plot, set the add parameter, add violin graph to the dot plot, and add the vertical line of mean standar
- Skiasharp's WPF self drawn drag ball (case version)
猜你喜欢

Router firmware decryption idea

15、用户web层服务(三)

Application of mobile face stylization Technology

强缓存、协商缓存具体过程

tolua之wrap文件的原理与使用

In order to ensure the normal operation of fire-fighting equipment in large buildings, the power supply monitoring system of fire-fighting equipment plays a key role

游戏流程与底层实现 逐步完成

Hcip (condition matching and OSPF packet related knowledge)

Design and implementation of SSM personal blog system

STL concept and its application
随机推荐
Direct insert sort and Hill sort
Docker runs MySQL service
Simple selection sort and heap sort
Redis installation
Redis安装
Specific functions of some multi parameter functions
ES6 knowledge points supplement
Solutions to the disappearance of Jupiter, spyder, Anaconda prompt and navigator shortcut keys
Specific process of strong cache and negotiation cache
STL concept and its application
多线程与高并发(三)—— 源码解析 AQS 原理
How is the JS code compiled and executed by the browser engine?
How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
Techniques for visualizing large time series.
游戏流程与底层实现 逐步完成
简单选择排序与堆排序
Hcip (configuration of GRE and mGRE and OSPF related knowledge)
Develop your own NPM package from 0
Update dev (development version) of the latest win11
Upgrading of computing power under the coordination of software and hardware, redefining productivity