Educational Codeforces Round 118 (Rated for Div. 2)ABC+半个E

21 篇文章 0 订阅
19 篇文章 0 订阅

题目链接

补题挖坑

A

码风淳朴勿喷呜呜,找位数关系,总位数大的就大,相等的凑到前面两个数相等然后继续比

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
ll t, n;
int main()
{
    cin >> t;
    while (t--)
    {
        ll a, b, p1, p2;
        cin >> a >> p1 >> b >> p2;
        ll x1 = a, x2 = b;

        ll a_len = 0, b_len = 0;
        while (a > 0)
        {
            a /= 10;
            a_len++;
        }
        while (b > 0)
        {
            b /= 10;
            b_len++;
        }
        // cout<<"dasdas" << a_len << ' ' << b_len << endl;
        if (p1 + a_len > p2 + b_len)
            cout << '>' << endl;
        else if (p1 + a_len < p2 + b_len)
            cout << '<' << endl;
        else
        {
            ll cnt = a_len - b_len;
            if (cnt > 0)
                x2 *= (ll)pow(10, cnt);
            else if (cnt < 0)
                x1 *= (ll)pow(10, -cnt);
            if (x1 > x2)
                cout << '>' << endl;
            else if (x1 < x2)
                cout << '<' << endl;
            else
                cout << '=' << endl;
        }
    }
    return 0;
}
B

找不到的话就每个数%第一小的数,输出 n 2 \frac{n}{2} 2n项就行了

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll t, n;

int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        vector<ll> a(n);
        for (auto &i : a)
            cin >> i;
        // unordered_map<int, bool> b;
        sort(a.begin(), a.end());
        int cnt = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            cout << a[i] << ' ' << a[0] << endl;
            cnt++;
            if (cnt >= n / 2)
                break;
        }
    }
    return 0;
}
C

二分答案,算是模板题目,不啦不啦

#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, b, t, h;
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n >> h;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        ll l = 1, r = h;
        while (l < r)
        {
            ll mid = l + r >> 1;
            int flag = 0;
            ll ans = 0;
            for (int i = 1; i < n; ++i)
            {
                ans += min(mid, a[i] - a[i - 1]);
            }
            ans += mid;
            if (ans < h)
                l = mid + 1;
            else
                r = mid;
        }
        cout << l << endl;
    }
    return 0;
}
E

写了一半wa3不知道错哪了看到现在,唉,大哥们可以帮忙看看,我要是会了的话就补上了(虽然很小概率补)
我的想法就是从L开始bfs搜索
如果临点的 f r e e 值 ≤ 1 free值\leq 1 free1就变+,free就是一个点周围的.的个数
之后如果扫到标记过的点但是临点是加号那就以防万一再扫一次
然后就挂了🐶

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
ll t, n, m;
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        bool M[n + 2][m + 2];
        memset(M, 0, sizeof(M));
        char a[n + 2][m + 2];
        memset(a, 0, sizeof(0));
        for (int i = 1; i <= n; i++)
            scanf("%s", a[i] + 1);
        bool flag = 0;
        queue<pair<int, int>> q;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (a[i][j] == 'L')
                {
                    q.push({i, j});
                    // M[i][j] = 1;
                    flag = 1;
                    break;
                }
            }
            if (flag)
                break;
        }
        while (q.size())
        {

            pair<int, int> now = q.front();
            // if(M[now.first][now.second] == 1)
            // {
            //     q.pop();
            //     continue;
            // }
            M[now.first][now.second] = 1;
            // cout << "check            " << now.first << ' ' << now.second << endl;
            q.pop();
            for (int k = 0; k < 4; k++)
            {
                pair<int, int> next(now.first + dx[k], now.second + dy[k]);
                // cout << "round   " << next.first << ' ' << next.second<<endl;
                // cout << a[next.first][next.second] << ' ' << M[next.first][next.second] << endl;
                if (next.first < 1 || next.second < 1 || next.first > n || next.second > m || a[next.first][next.second] == '#' )
                    continue;
                if(M[next.first][next.second] == 1)
                {
                    if(!(a[next.first][next.second]=='.'&&(a[now.first][now.second] == 'l'||a[now.first][now.second] =='L')))
                        continue;
                }
                // cout << "round   xxx" << next.first << ' ' << next.second<<endl;

                if (a[now.first][now.second] == 'L' || a[now.first][now.second] == 'l')
                {
                    q.push(next);
                    int free = 0;
                    for (int j = 0; j < 4; j++)
                    {
                        pair<int, int> next2(next.first + dx[j], next.second + dy[j]);
                        if (a[next2.first][next2.second] == '.')
                        {
                            // cout << "dasdasdas   " << next2.first << ' ' << next2.second<<endl;
                            free++;
                        }
                    }
                    if (free <= 1)
                    {
                        a[next.first][next.second] = 'l';
                        // cout << next.first << ' ' << next.second << ' ' << free << endl;
                    }
                }
            }
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (a[i][j] == 'l')
                    printf("+");
                else
                    printf("%c", a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}
/*
1
3 2
.#
..
L.
*/

有能力再继续补
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数学小牛马

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值