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排个序,

分类讨论

  1. 个人最多的聚会>=其余n-1 人的聚会,这里答案就很清楚了
  2. 个人最多的聚会<其余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的更多相关文章

  1. Codeforces Round #744 (Div. 3) G题题解

    淦,最后一道题没写出来,...还是我太菜了,不过这个题确实比较有趣. G. Minimal Coverage 简化题意:就是你处在坐标轴的0点上,给你一个序列\(a_i\),每次你可以选择向左走\(a ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. [Codeforces Round #340 (Div. 2)]

    [Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...

  4. Codeforces Round 254 (Div. 2)

    layout: post title: Codeforces Round 254 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  5. Codeforces Round #678 (Div. 2)

    Codeforces Round #678 (Div. 2) A. Reorder 题意:有一个有 n 个数的序列 a ,以及一个数 m ,问能否给序列a重新排序,能够满足式子 $\sum_{i=1} ...

  6. 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 在这道题目中,不可以真正地进行寻 ...

  7. 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 ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  10. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. P5733 自动修正

    字符串题解第一弹~ [千万不能错过的原题连接](https://www.luogu.com.cn/problem/P5733) 今天就研究一下这道自动修正问题哈 首先,我们看到了小写转大写的时候,就知 ...

  2. (python)正则表达式

    # -*- coding: utf-8 -*- import re def test_dot(): """ . => 表示匹配任意字符 ""&q ...

  3. chatGPT-meta抗衡版本

    chatGPT-meta抗衡版本 链接:https://mp.weixin.qq.com/s/MbZTfVgxx221Eo9pl1h80w 内置 git代码 LLaMA 项目地址:https://gi ...

  4. 下载base64图片

    下载 this.downloadFile('二维码',that.img64) downloadFile(fileName, content) { let aLink = document.create ...

  5. IT部门一线主管要如何才能对员工的某项工作的时间和难度评估心里有数?

    自己去处理一些棘手的问题,并趁此机会了解系统的逻辑,评估复杂度,是复杂度,不是具体的内容,然后把这个印象记住. 定一个需求,请员工去做,看看完成到底需要多久,在做的过程中或者做完之后,跟他讨论实现的过 ...

  6. 回溯-1-N皇后(Backtracking-1-N Queens)

    #include <stdio.h> #define N 4 enum bool {TRUE, FALSE}; void print_Q(int *Q) { int i; for (i = ...

  7. .netcore webapi的返回值和过滤器

    1.返回值. 1.1直接返回数据 1.2 数据+状态码 返回这种类型IActionResult 可以使用return OK(T).return NotFound(T) 1.3前两种的混合使用Actio ...

  8. GIT迁移仓库地址时如何保留分支和历史记录

    需求背景 GIT仓库(GitLab)所在服务器因某些原因要关停,相关服务需转移到另外一台机器上. 操作步骤 # clone项目 git clone --mirror http://192.168.12 ...

  9. R7-1 判断回文字符串

    R7-1 判断回文字符串 分数 15 全屏浏览题目 切换布局 作者 颜晖-历年试卷 单位 浙大城市学院 输入一个字符串,判断该字符串是否为回文.回文就是字符串中心对称,从左向右读和从右向左读的内容是一 ...

  10. outlook初用

    以前一直用 Foxmail 收发邮件,由于公司用到 sharepoint 可以跟 outlook 绑定,试了下 outlook. 第一次用 outlook 以为也是跟 foxmail 一样简单配置一下 ...