首页 > 其他分享 >AtCoder ABC 358

AtCoder ABC 358

时间:2024-06-21 16:31:32浏览次数:28  
标签:tmp AtCoder ABC int namespace long include 358 define

比赛链接

A - Welcome to AtCoder Land

AC_Code

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    string s,t;
    cin >> s >> t;
    if(s == "AtCoder" && t == "Land")
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

B - Ticket Counter

AC_Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
int t[110];

signed main()
{
    int n,a;
    cin >> n >> a;
    for(int i = 1; i <= n; i++)
        cin >> t[i];
    int last = 0;
    for(int i = 1; i <= n; i++)
    {
        last = max(last,t[i]) + a;
        cout << last << "\n";
    }
    return 0;
}

C - Popcorn

AC_Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
string s[20];
int val[20];

signed main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> s[i];
        val[i] = 0;
        for(int j = 0; j < s[i].length(); j++)
            val[i] = val[i] * 2 + (s[i][j] == 'o' ? 1 : 0);
    }
    int ans = n;
    for(int s = 0; s < (1 << n); s++)
    {
        int now = 0,cnt = 0;
        for(int i = 1; i <= n; i++)
        {
            if(s & (1 << (i - 1)))
                now |= val[i],cnt++;
        }
        if(now == (1 << m) - 1)
            ans = min(ans,cnt);
    }
    cout << ans << "\n";
    return 0;
}

D - Souvenirs

AC_Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[200010],b[200010];

signed main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int j = 1; j <= m; j++)
        cin >> b[j];
    sort(a + 1,a + n + 1);
    sort(b + 1,b + m + 1);
    int pos1 = 1,ans = 0;
    bool flag = true;
    for(int i = 1; i <= m; i++)
    {
        int l = pos1,r = n,tmp = -1;
        while(l <= r)
        {
            int mid = (l + r) >> 1;
            if(a[mid] < b[i])
                l = mid + 1;
            else
                r = mid - 1,tmp = mid;
        }
        if(tmp == -1 || a[tmp] < b[i])
        {
            flag = false;
            break;
        }
        ans += a[tmp];
        pos1 = tmp + 1;
    }
    if(flag)
        cout << ans << "\n";
    else
        cout << "-1\n";
    return 0;
}

E - Alphabet Tiles

AC_Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353
int c[30],dp[30][1010],C[2010][2010];

void init()
{
    for(int i = 0; i <= 2000; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            if(i == j || j == 0)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            C[i][j] %= mod;
        }
    }
}

signed main()
{
    int k;
    cin >> k;
    init();
    for(int i = 1; i <= 26; i++)
        cin >> c[i];
    dp[0][0] = 1;
    for(int i = 1; i <= 26; i++)
    {
        for(int j = 0; j <= k; j++)
        {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
            for(int l = 1; l <= c[i]; l++)
            {
                if(l > j)
                    break;
                dp[i][j] += dp[i - 1][j - l] * C[j][l];
                dp[i][j] %= mod;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= k; i++)
        ans += dp[26][i],ans %= mod;
    cout << ans << "\n";
    return 0;
}

标签:tmp,AtCoder,ABC,int,namespace,long,include,358,define
From: https://www.cnblogs.com/cookiebread/p/18260812/ABC358Summary

相关文章

  • AtCoder Beginner Contest 357-F
    Problem同步于博客ProblemYouaregivensequencesoflength\(N\),\(A=(A_1,A_2,\ldots,A_N)\)and\(B=(B_1,B_2,\ldots,B_N)\).Youarealsogiven\(Q\)queriestoprocessinorder.Therearethreetypesofqueries:1lrx:Add\(x\)toeachof......
  • RK3588J + 麒麟系统,“软硬件”全国产——让您的产品更具竞争力!
    银河麒麟嵌入式操作系统简介银河麒麟嵌入式操作系统V10是面向物联网及工业互联网场景的安全实时嵌入式操作系统,具备信息安全、多域隔离、云边端协同、多样性算力支持等特点,可满足嵌入式场景对操作系统小型化、可靠性、安全性、实时性、互联性的需求。 银河麒麟嵌入式操作系统V......
  • AT_abc_G选刷
    AT_abc_G选刷目录AT_abc_G选刷ABC332G题目大意solutionABC331G题目大意solutionABC328G题目大意solutionABC326G题目大意solutionABC324G题目大意solutionABC350G题目大意solutiontipsABC352G题目大意solutionABC332G题目大意给定n种球,每种分别有\(a_i\)个,有m个盒子,每个盒子可......
  • ABC 328F Good Set Query
    题意直接看题吧https://atcoder.jp/contests/abc328/tasks/abc328_f题解本题主要考了带权并查集,具体实现是在路径压缩的时候顺便维护一下边权(其中w[i]表示点i距离它的祖先的边权之和,fa[i]是点i的祖先)。依次遍历每一次询问,如果询问中的a与b拥有公共祖先,也就是在同一个并查集里......
  • 【国赛赛题详解】2024年数学建模国赛ABCDEF题(点个关注,后续会更新)
     您的点赞收藏是我继续更新的最大动力!一定要点击如下的蓝色字体链接,那是获取资料的入口!点击链接加入群聊【2024国赛资料合集】:http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=eQt5WRIvc5-fogZRrrahAhbqDa2nKfW8&authKey=%2BqQfThTxNnhw5LGJFRIcneF8JXBj1ufd2K01UpKPrpcgkKDskF......
  • ABC358
    E-AlphabetTileshttps://atcoder.jp/contests/abc358/tasks/abc358_e方案数DP。先看摆花(五年前做过)。记\(f_{i,j}\)表示摆完前\(i\)种花,目前已经有了\(j\)盆花的方案数。可以考虑先枚举当前摆第\(i\)种花,然后再枚举摆完第\(i\)种花之后,目前已经有了\(j\)盆......
  • 海思SD3403,SS928/926,hi3519dv500,hi3516dv500移植yolov7,yolov8(22)hi3516dv500/19dv5
     最近太忙更新不及时,SS928跑yolov8的文章各位朋友不要催,最近在测试自己魔改的yolov8,测完有结论了跟大家分享。魔改的yolov8在dv500系列里有些小问题,能正常运行,但是优化报错,在做更细致的测试。 先分享一下最近对比RK3588做的测试结果。RK3588算是嵌入式AI里的顶配级别存在......
  • ABC353F 分讨
    回来补补题。分析:我先考虑\(k\)很大的时候,大块和大块间的移动,我们不得不尽量避免小块:我们容易发现这样时是最优的,可以发现就是在斜着走,也就是典型的切比雪夫距离。斜着走一次需要经过两条边,所以花费是两倍的切比雪夫距离。要是起点和终点不在大块上呢?首先考虑它们不在同一......
  • AtCoder Beginner Contest 358
    A-WelcometoAtCoderLandvoidsolve(){strings,t;cin>>s>>t;if(s=="AtCoder"&&t=="Land"){cout<<"Yes\n";return;}cout<<"No\n&qu......
  • 【国赛赛题详解】2024年数学建模国赛ABCDEF题(点个关注,后续会更新)
     您的点赞收藏是我继续更新的最大动力!一定要点击如下的蓝色字体链接,那是获取资料的入口!点击链接加入群聊【2024国赛资料合集】:http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=eQt5WRIvc5-fogZRrrahAhbqDa2nKfW8&authKey=%2BqQfThTxNnhw5LGJFRIcneF8JXBj1ufd2K01UpKPrpcgkKDskF......