Codeforces 康复训练 -- Codeforces Round #713 (Div. 3)

Codeforces Round #713 (Div. 3)

A. Spy Detected!

题目大意:
首先是T组数据,然后输入一个n,然后接下来n个数,让你找到跟其他数字不一样的数字的下标是多少
由于数据范围极其的水,我们可以花式暴力做

代码实现:

#include<bits/stdc++.h>
 
using namespace std;
 
int a[110],b[110];
signed main()
{
    //freopen("in.txt","r",stdin);
    int T;
    scanf("%d",&T);
    while(T--)
    {
        memset(a,0,sizeof(a));
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&b[i]);
            a[b[i]]++;
        }
        int pos=0;
        for(int i=1;i<=100;i++)
        {
            if(a[i]==1)pos=i;
        }
        for(int i=1;i<=100;i++)
        {
            if(b[i]==pos)
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

[B. Almost Rectangle](Problem - B - Codeforces)

题目大意:

首先是T组数据,然后给定一个整数n,接下来就是n*n的一个二维字符数组,然后我们输入这个,接下来会有三种情况,第一种就是两个星号都在同一行或者同一列,那么我们要做的事情就是在它的同一行或者同一列的左侧右侧,或者是上侧下侧填充上两个星号,如果不是同一行或者同一列,那么我们可以直接在(x1,y2),(x2,y1)这两个位置填充上星号输出即可

代码实现:

#include <bits/stdc++.h>

using namespace std;

char s[410][410];

void solve()
{
    memset(s, '.', sizeof(s));
    int n;
    scanf("%d", &n);
    bool flag = true;
    int x1, x2, y1, y2;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            char temp;
            cin >> temp;
            if (temp == '*' && flag)
            {
                flag = false;
                s[i][j] = '*', x1 = i, y1 = j;
            }
            else if (temp == '*' && !flag)
            {
                s[i][j] = '*', x2 = i, y2 = j;
            }
        }
    }
    if (x1 == x2)
    {
        if (x1 + 1 <= n)
        {
            s[x1 + 1][y1] = '*', s[x1 + 1][y2] = '*';
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                    cout << s[i][j];
                puts("");
            }
        }
        else
        {
            s[x1 - 1][y1] = '*', s[x1 - 1][y2] = '*';
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                    cout << s[i][j];
                puts("");
            }
        }
    }
    else if (y1 == y2)
    {
        if (y1 + 1 <= n)
        {
            s[x1][y1 + 1] = '*', s[x2][y2 + 1] = '*';
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                    cout << s[i][j];
                puts("");
            }
        }
        else
        {
            s[x1][y1 - 1] = '*', s[x2][y2 - 1] = '*';
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                    cout << s[i][j];
                puts("");
            }
        }
    }
    else
    {
        s[x1][y2] = '*', s[x2][y1] = '*';
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
                cout << s[i][j];
            puts("");
        }
    }
}
signed main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        solve();
    }
    return 0;
}

[C. A-B Palindrome](Problem - C - Codeforces)

题目大意:

首先是T组数据,然后给定一个一个确切的a和b的值,就是表示接下来的那个字符串里面究竟有多少个a有多少个b,然后里面还会有 ? 这个可以随意的变成a或者是b,然后我们要尽力把它构成回文串,如果可以输出最后的那个回文串,否则输出-1

代码实现


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值