栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

2021-10-11Codeforces Round #731 (Div. 3)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021-10-11Codeforces Round #731 (Div. 3)

Codeforces Round #731 (Div. 3) A. Shortest Path with Obstacle

题目入口

思路:特判一条线的情况,其他为曼哈顿距离
代码

#include
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int x1,y1,x2,y2,x3,y3;
        cin>>x1>>y1>>x2>>y2>>x3>>y3;
        if(x1==x2&&x1==x3&&y3>=min(y1,y2)&&y3<=max(y1,y2)) cout<=min(x1,x2)&&x3<=max(x1,x2)) cout< 
B. Alphabetical Strings 

题目入口

思路:找到a的位置后模拟即可
代码

#include
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int pos=-1;
        for(int i=0;i=0||pos+j<=s.size()-1))
        {
            if(s[pos-i]==last+1)
            {
                last=s[pos-i];
                i++;
            }
            else if(s[pos+j]==last+1)
            {
                last=s[pos+j];
                j++;
            }
            else flag=false;
        }
        if(flag) cout<<"YES"< 
C. Pair Programming 

题目入口

思路:模拟即可
代码

#include
using namespace std;
const int N=300;
int t;
int k,n,m;
int a[N],b[N];
vector res;
int main()
{
    cin>>t;
    while(t--)
    {
        res.clear();
        cin>>k>>n>>m;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=m;i++) cin>>b[i];
        int i=1,j=1;
        bool flag=true;
        while(i<=n||j<=m)
        {
            //cout<<"1";
            if(a[i]==0&&i<=n)
            {
                res.push_back(0);
                i++;
                k++;
            }
            else if(b[j]==0&&j<=m)
            {
                res.push_back(0);
                j++;
                k++;
            }
            else if(a[i]&&a[i]<=k&&i<=n)
            {
                res.push_back(a[i]);
                i++;
            }
            else if(b[j]&&b[j]<=k&&j<=m)
            {
                res.push_back(b[j]);
                j++;
            }
            else
            {
                flag=false;
                break;
            }
        }
        if(flag)
        {
            for(auto ans:res) cout< 
D. Co-growing Sequence 

题目入口

思路:可知第一项必为0,则对后面一个x的每一位进行判断,只有当当前位必须为1时更新
代码

#include
#define int long long
using namespace std;
const int N=2e5+5;
int t;
int n;
int a[N];
int res[N];
signed main()
{
    cin>>t;
    while(t--)
    {
        memset(res,0,sizeof(res));
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=2;i<=n;i++)
        {
            for(int j=30;j>=0;j--)
            {
                int check=a[i-1]>>j&1;
                int now=a[i]>>j&1;
                if(now==0&&check==1)
                {
                    res[i]^=(1< 
E. Air Conditioners 
F. Array Stabilization (GCD version) 
G. How Many Paths?
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/317312.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号