Codeforces Round 972 (Div. 2) 总结
A
#include <bits/stdc++.h>
using namespace std;
int n;
char a[]={'a','e','i','o','u'};
void solve()
{
cin>>n;
int x=n/5,y=n%5;
for(int i=0;i<5;i++)
{
for(int j=1;j<=x;j++) cout<<a[i];
if(y) cout<<a[i],y--;
}
cout<<'\n';
}
int main ()
{
int T;
cin>>T;
while(T--) solve();
return 0;
}
B1
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,q;
int b[N];
void solve()
{
cin>>n>>m>>q;
for(int i=1;i<=m;i++) cin>>b[i];
sort(b+1,b+m+1);
while(q--)
{
int x;
cin>>x;
if(x<b[1]) cout<<b[1]-1<<"\n";
else if(x<b[2]) cout<<(b[2]-b[1])/2<<"\n";
else cout<<n-b[2]<<"\n";
}
}
int main ()
{
int T;
cin>>T;
while(T--) solve();
return 0;
}
B2
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,q;
int b[N];
void solve()
{
cin>>n>>m>>q;
for(int i=1;i<=m;i++) cin>>b[i];
sort(b+1,b+m+1);
while(q--)
{
int t;
cin>>t;
int x=lower_bound(b+1,b+m+1,t)-b-1;
int y=x+1;
if(x==0) cout<<b[y]-1<<"\n";
else if(y==m+1) cout<<n-b[x]<<"\n";
else cout<<(b[y]-b[x])/2<<"\n";
}
}
int main ()
{
int T;
cin>>T;
while(T--) solve();
return 0;
}
C
#include <bits/stdc++.h>
using namespace std;
const int N=1005,inf=1e9;
string S="narek";
int n,m;
string s;
int f[N][5];
void solve()
{
cin>>n>>m;
for(int i=0;i<=n;i++)
for(int j=0;j<5;j++)
f[i][j]=-1e9;
f[0][0]=0;
for(int i=1;i<=n;i++)
{
cin>>s;
for(int j=0;j<5;j++) f[i][j]=f[i-1][j];
for(int j=0;j<5;j++)
{
if(f[i-1][j]==-inf) continue;
int sum=0,ne=j;
for(int k=0;k<m;k++)
{
int id=S.find(s[k]);
if(id==-1) continue;
if(ne==id)
{
ne=(ne+1)%5;
sum++;
}
else sum--;
}
f[i][ne]=max(f[i][ne],f[i-1][j]+sum);
}
}
int ans=0;
for(int i=0;i<5;i++) ans=max(ans,f[n][i]-2*i);
cout<<ans<<'\n';
}
int main ()
{
int T;
cin>>T;
while(T--) solve();
return 0;
}
标签:972,int,namespace,cin,Codeforces,--,while,solve,Div
From: https://www.cnblogs.com/zhouruoheng/p/18500953