当前位置:网站首页>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;
}
边栏推荐
- R language uses dplyr package group_ By function and summarize function calculate the mean value of all covariates involved in the analysis based on grouped variables (difference in means of covariate
- Network communication protocol classification and IP address
- [pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?
- 强缓存、协商缓存具体过程
- How is the JS code compiled and executed by the browser engine?
- Hcip (condition matching and OSPF packet related knowledge)
- [general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
- Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
- An example of the mandatory measures of Microsoft edge browser tracking prevention
- Anonymous subclass objects of abstract classes
猜你喜欢

PFP会是数字藏品的未来吗?

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

瑞吉外卖——Day01

Lua makes a deep copy of table

Detailed explanation of boost official website search engine project

Are interviews all about memorizing answers?
![[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials](/img/46/830b7703ae7cbfa6051137061560c2.png)
[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials

Globalthis is not defined solution

15、用户web层服务(三)

Application of mobile face stylization Technology
随机推荐
Reflect 机制获取Class 的属性和方法信息
[diary of supplementary questions] [2022 Niuke summer school 2] h-take the elevator
多线程与高并发(三)—— 源码解析 AQS 原理
Static proxy instance
Detailed explanation of boost official website search engine project
[collection] Advanced Mathematics: Capriccio of stars
async await如何实现并发
Who's the big God help? Let's see how Oracle number type parsing works. Struct{scale=15, Val
Lua对table进行深拷贝
Stored state and running state of program
Service Workers让网站动态加载Webp图片
Hcip (condition matching and OSPF packet related knowledge)
Network communication protocol classification and IP address
The fifth generation verification code of "cloud centered, insensitive and extremely fast" is coming heavily
Start from scratch blazor server (2) -- consolidate databases
An example of the mandatory measures of Microsoft edge browser tracking prevention
【补题日记】[2022牛客暑期多校2]I-let fat tension
Advanced database technology learning notes 1 -- Oracle deployment and pl/sql overview
[diary of supplementary questions] [2022 Niuke summer multi school 2] i-let fat tension
Unity中使用UnityWebRequest进行网络和本地图片加载