上分之路 VP Codeforces Round #744 (Div. 3) ABDE
VP情况 4 / 8
AC: A,B,D,E1 60 minutes
WA: C
| 4 | 127 | +00:02 | +00:28 | -7 | +00:58 | +00:39 | |
手速还在线
D pair排个序,
分类讨论
- 个人最多的聚会>=其余n-1 人的聚会,这里答案就很清楚了
- 个人最多的聚会<其余n-1 人的聚会,将编号加入新数组里,
数组下标,1~n/2 ~ n,这里就输出a[1~n/2],a[n/2+1~n]为答案
感觉这里和某A题一样。
// AC one more times
bool cmp1(PII c, PII d) { return c.fi > d.fi; } void solve()
{
int n; cin>>n;
vector<PII> a;
for(int i=1;i<=n;i++)
{
int x; cin>>x;
if(x==0) continue;
else
a.push_back({x,i});
}
sort(a.begin(),a.end(),cmp1);
int len=a.size(),sum=0;
for(int i=1;i<len;i++)
sum+=a[i].fi;
if(a[0].fi>=sum)
{
cout<<sum<<endl;
for(int i=1;i<len;i++)
while(a[i].fi--)
cout<<a[0].se<<" "<<a[i].se<<endl;
}
else
{
vector<int> b;
for(auto it : a)
{
int ti=it.fi,na=it.se;
while(ti--)
{
b.push_back(na);
}
}
sort(b.begin(),b.end());
cout<<b.size()/2<<endl;
int f=b.size()/2-1,f2=b.size()-1;
for(int i=f;i>=0;i--)
{
cout<<b[i]<<" "<<b[f2]<<endl;
f2--;
}
}
return;
} int main()
{
std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int T;cin>>T;for(int i=1;i<=T;i++)
solve(); return 0;
}
B模拟,先确定大的数,通过左移到位置上,n-1次操作就能完成。
// AC one more times
struct ans
{
int l,r,d;
}; void solve()
{
ans res[55];
int cnt=0;
int n; LL a[55];
cin>>n;
LL b[55];
for(int i=1;i<=n;i++)
{
cin>>a[i]; b[i]=a[i];
}
sort(b+1,b+1+n); for(int i=n;i>=2;i--)
{
LL t=b[i];
for(int j=i;j>=1;j--)
{
if(a[j]==t&&i==j) break;
if(a[j]==t&&i!=j)
{
res[++cnt]={1,i,j};
int times=j;
while(times--)
{
LL q=a[1];
for(int k=2;k<=i;k++)
a[k-1]=a[k];
a[i]=q;
}
break;
}
}
} cout<<cnt<<endl;
for(int i=1;i<=cnt;i++)
cout<<res[i].l<<" "<<res[i].r<<" "<<res[i].d<<endl;
return;
}
int main()
{
std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int T;cin>>T;for(int i=1;i<=T;i++)
solve(); return 0;
}
E1 按字典序加入双端队列就出来了
C假题了,一直没有调出来wa2
正确作法是找点 '* '从左上和右上方向遍历,记录路径长度,直到其中有一方超出边界或者点不为 '*',终止。如果路径长度大于等于d就将路径上的每个点标记值++
最后check ,如果有点为 '*'但标记值为0就说明不符合条件
细节见代码:
// AC one more times
int cnt, c[100][100],n,m,k;
char op[100][100];
bool st;
int d; void search(int x,int y)
{
int t1x=x,t2x=x,t1y=y,t2y=y;
while(1)
{
int jishu=0;
t1x=t1x-1,t1y=t1y-1;
t2x=t2x-1,t2y=t2y+1;
if(t1x>=0&&t1x<n&&t1y>=0&&t1y<m)
if(op[t1x][t1y]=='*')
jishu++;
if(t2x>=0&&t2x<n&&t2y>=0&&t2y<m)
if(op[t2x][t2y]=='*') jishu++;
if(jishu<2) break;
cnt++;
} if(cnt>=k)
{
c[x][y]++;
t1x=t2x=x,t1y=t2y=y;
while(cnt--)
{
t1x=t1x-1,t1y=t1y-1;
t2x=t2x-1,t2y=t2y+1;
if(t1x>=0&&t1x<n&&t1y>=0&&t1y<m)
if(op[t1x][t1y]=='*')
c[t1x][t1y]++;
if(t2x>=0&&t2x<n&&t2y>=0&&t2y<m)
if(op[t2x][t2y]=='*')
c[t2x][t2y]++;
}
}
}
void solve()
{
cin>>n>>m>>k;
st=false; memset(c,0,sizeof c);
for(int i=0;i<n;i++) cin>>op[i]; for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if( op[i][j]=='*' &&
( i-1>=0 && j-1>=0 && j+1<m) )
{ cnt=0;
search(i,j);
}
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(op[i][j]=='*'&&c[i][j]<=0)
st=true;
else if(op[i][j]=='.'&&c[i][j]>=1)
st=true;
if(st)
cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return;
} int main()
{
std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int T;cin>>T;for(int i=1;i<=T;i++)
solve(); return 0;
}
上分之路 VP Codeforces Round #744 (Div. 3) ABDE的更多相关文章
- Codeforces Round #744 (Div. 3) G题题解
淦,最后一道题没写出来,...还是我太菜了,不过这个题确实比较有趣. G. Minimal Coverage 简化题意:就是你处在坐标轴的0点上,给你一个序列\(a_i\),每次你可以选择向左走\(a ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- [Codeforces Round #340 (Div. 2)]
[Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...
- Codeforces Round 254 (Div. 2)
layout: post title: Codeforces Round 254 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round #678 (Div. 2)
Codeforces Round #678 (Div. 2) A. Reorder 题意:有一个有 n 个数的序列 a ,以及一个数 m ,问能否给序列a重新排序,能够满足式子 $\sum_{i=1} ...
- Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round(C,D题解)
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round C - Zero Path 在这道题目中,不可以真正地进行寻 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
随机推荐
- 【服务器数据恢复】RAID6数据恢复案例
服务器数据恢复环境:一台Web服务器中有一组由8块磁盘组建的raid6磁盘阵列,用来运行数据库和存储普通办公文件. 服务器故障:服务器raid6磁盘阵列中有两块硬盘离线,但是管理员没有注意到这种情况, ...
- QE11 / QE51N 界面太小问题
修复后界面是,修复前常规页签中的数据只能显示4行,需要的note是 2639352 , SNOTE 进行打补丁就好 note是 2639352
- jenkins+stf+airtest实现移动端自动化测试平台
背景: 公司android测试机比较多没有统一的管理: app自动化测试时获取设备的状态比较麻烦,通过STF可以轻松获取: 自动化异常场景时.可远程操控设备: 需要随时了解设备情况: 装逼 前提: 已 ...
- C++ 11 数字转字符串新功能
// 头文件 <string>string to_string (int val);string to_string (long val);string to_string (long l ...
- color-color diagram data
- printf函数size_t的替换字符串zu
参考:https://stackoverflow.com/questions/2524611/how-can-one-print-a-size-t-variable-portably-using-th ...
- centos 6.5 docker 安装
https://www.cnblogs.com/zhangzhen894095789/p/6641981.html?utm_source=itdadao&utm_medium=referral
- Ubuntu常用备查
Ubuntu的目录结构 / 根目录 /home 用户操作目录 /etc 配置文件存放 /boot 系统启动文件 /usr 非系统自带的软件安装目录 /bin./usr/bin 存放可执行二进制文件 / ...
- liunx部署flask项目
如何在linux上部署flask项目 Python3.7 + virtualenv + uwsgi + git + mysql-5.6.45 + nginx 源码编译安装所需要的环境 yum inst ...
- Ribbon负载均衡调用
pring cloud Ribbon 是基于Netfilix Ribbon 实现一套 客户端 负载均衡工具. 简单的说, Ribbon 是 Netflix 发布开源项目. 主要是提供客户端软件负载均衡 ...