总结:AB很水,尽量快速AC掉,拿掉尽可能多的分,C也是必须攻克的,还有时间就写写D,后面的可以不看了(果然本场F爆0)
A题:输入a b c d输出b c c / a c c也行 送分题
B题 :怪物有hp 然后有m次怪物血量吸纳操作和n次雷击操作 问你能不能干死怪物 - - 直接模拟吧 while 吸纳次数操作完 再判断雷击总伤害能不能干死怪物 (终榜码怪截图)
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
#define fi first
#define se second
#define pb push_back
#define si size()
#define E exp(1.0)
#define maxn 200005
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#define IOS ios::sync_with_stdio(false);cin.tie(0)
//#define rep(i,m,n) for(int (i)=(m);(i)<=(n);(i)++)
using namespace std;
inline ll read()
{
char c=getchar();
ll f=1,x=0;
while(c<'0'||c>'9')
{
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=(x<<1)+(x<<3)+(c^'0');
c=getchar();
}
return x*f;
}
ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b); //最大公因数
}
int main()
{
ll t=read();
while(t--)
{
ll a=read();
ll b=read();
ll c=read();
while(b&&a>20){
b--;
a=a/2+10;
}
if(a>c*10) printf("NO\n");
else printf("YES\n");
}
return 0;
}
C 题:(本来还以为可以用到LCA)n个城市 选k个城市是工业城市 剩下的全是旅游城市,问工业城市到首都(1)途中旅游城市数量之和的最大值。 显然,尽可能的把旅游城市分布在离首都最近是最优的,按照深度-子树数目排序取前k大即可。
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define si size()
#define E exp(1.0)
#define maxn 200005
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#define IOS ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
inline ll read()
{
char c=getchar();
ll f=1,x=0;
while(c<'0'||c>'9')
{
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=(x<<1)+(x<<3)+(c^'0');
c=getchar();
}
return x*f;
}
/*
void dfs(int prev,int rt){
depth[rt]=depth[prev]+1;
fa[rt][0]=prev;
for (int i=1;i<20;i++)
fa[rt][i]=fa[fa[rt][i-1]][i-1];
for (int i=0;i<son[rt].size();i++)
dfs(rt,son[rt][i]);
}
int LCA(int x,int y){
if (depth[x]<depth[y])
swap(x,y);
for (int i=19;i>=0;i--)
if (depth[x]-(1<<i)>=depth[y])
x=fa[x][i];
if (x==y)
return x;
for (int i=19;i>=0;i--)
if (fa[x][i]!=fa[y][i])
x=fa[x][i],y=fa[y][i];
return fa[x][0];
}*/
const int manx=2e5+9;
vector<ll>g[manx];
vector<pair<ll,ll> >a;
ll cnt[manx];
ll d[manx];
ll col[manx];
ll n,k,ans=0;
void dfs(ll u,ll pre){
d[u]=d[pre]+1; cnt[u]=1;
for(auto v: g[u]){
if(v==pre) continue;
dfs(v,u);
cnt[u]+=cnt[v];
}
a.pb(mp(d[u]-cnt[u],u));
}
char s[1009];
int main()
{
n=read();
k=read();
for(int i=1;i<n; i++)
{
ll u=read();
ll v=read();
g[v].pb(u);
g[u].pb(v);
}
dfs(1,0);
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
for(int i=0; i<k; i++)
{
ans+=a[i].first;
}
printf("%lld\n",ans);
return 0;
}
D题 :C做完了 排名400多好像,然后开始了漫长的罚坐,排名- -
D其实就是三种宝石各有n m k个 然后就是ni mi ki的重量 求的是那个三元组的最小值,暴力forforfor直接炸裂,于是想到了枚举的方法,枚举其中一种然后用lowerbound+特判找寻另一种宝石的值,最后一种采取二分法,当然先要sort一下。按照此法 有6种情况,减以封装成函数去做
核心代码, 多多思考
ll checks(ll a[],ll a1,ll b[],ll b1,ll c[],ll c1)
{
ll add=2e18,x,y,z;
for(int i=1; i<=a1; i++)
{
x=a[i];
ll k=lower_bound(b+1,b+1+b1,x)-b;
if(k>=1&&k<=b1&&b[k]>=x)
y=b[k];
else
continue;
ll l=1,r=c1;
while(l<r)
{
int mid=(l+r+1)>>1;
if(c[mid]<=x)
{
l=mid;
}
else
{
r=mid-1;
}
}
if(c[l]<=x)
{
z=c[l];
}
else
{
continue;
}
ll d=(y-z)*(y-z)+(x-y)*(x-y)+(x-z)*(x-z);
if(d<add)
{
add=d;
}
}
return add;
}
本场结束rating达到1860 距离上紫还差40分 需要刷大量1900 难度分的题继续提升 每日坚持打卡效果还是挺明显
封榜的时候排名503