• Educational Codeforces Round 155 (Rated for Div. 2)


    Dashboard - Educational Codeforces Round 155 (Rated for Div. 2) - Codeforces

    A. Rigged!

    只要后面有选手大于或等于第一个选手的力量和耐力就会获胜或者平局,故这种情况判为-1,其余情况以第一位选手的力量为重量可以取到最优解

    1. #include
    2. using namespace std;
    3. typedef long long ll;
    4. void solve()
    5. {
    6. ll n, x, y, s, e;
    7. ll flag = 0;
    8. cin >> n;
    9. cin >> x >> y;
    10. for(int i = 2; i <= n; i ++)
    11. {
    12. cin >> s >> e;
    13. if(s >= x && e >= y)flag = 1;
    14. }
    15. if(flag)cout << -1 << '\n';
    16. else cout << x << '\n';
    17. }
    18. int main()
    19. {
    20. ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    21. int t;
    22. cin >> t;
    23. while(t --)
    24. {
    25. solve();
    26. }
    27. return 0;
    28. }

    B. Chips on the Board

    每行或每列都要选一个,对于每行选择每列代价最小的那个,对于每列列选择每行代价最小的那个,最终选取这两种方案的最小值即可

    1. #include
    2. using namespace std;
    3. typedef long long ll;
    4. const int N = 3e5 + 10;
    5. ll a[N], b[N];
    6. void solve()
    7. {
    8. ll n;
    9. cin >> n;
    10. ll s1 = 0, s2 = 0;
    11. for(int i = 1; i <= n; i ++)cin >> a[i];
    12. for(int i = 1; i <= n; i ++)cin >> b[i];
    13. sort(a + 1, a + 1 + n);
    14. sort(b + 1, b + 1 + n);
    15. for(int i = 1; i <= n; i ++)
    16. {
    17. s1 += a[1] + b[i];
    18. s2 += b[1] + a[i];
    19. }
    20. cout << min(s1, s2) << '\n';
    21. }
    22. int main()
    23. {
    24. ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    25. ll t;
    26. cin >> t;
    27. while(t --)
    28. {
    29. solve();
    30. }
    31. return 0;
    32. }

    C. Make it Alternating

    第一问:求删除数的个数,对于这题只需要减去重复的数即可,eg.1001111可以转化为1,2,4也就是相同的数就放在一起,然而对于每一个数不能有连续一样的,故每次删掉相同的数最后这几个数只剩下一个即可。

    第二问:需要求两点:

    1.重复元素有len个,我们需要删去len - 1个,故在这len个元素中挑出len - 1个元素即可,挑出这些数的方法有C(len,len-1)种

    2.对于挑出的所有的数中又可以进行任意的组合,这些组合的方案数为挑出元素个数的阶乘

    将1 * 2为所有的方案数

    注意初始就使用init,算出阶乘

    1. #include
    2. using namespace std;
    3. typedef long long ll;
    4. const int M = 2e5 + 10, mod = 998244353, N = 2e5 + 10;;
    5. ll p[N];
    6. ll c(ll x, ll y)
    7. {
    8. x *= y;
    9. return x % mod;
    10. }
    11. void init()
    12. {
    13. p[0] = p[1] = 1;
    14. for(int i = 2; i < M; i ++)
    15. {
    16. p[i] = c(i, p[i - 1]);
    17. }
    18. }
    19. void solve()
    20. {
    21. string s;
    22. ll num = 1, cur = 0, res = 1;
    23. cin >> s;
    24. ll n = s.size();
    25. for(int i = 0; i < n; i ++)
    26. {
    27. if(i && s[i] != s[i - 1])
    28. {
    29. num ++;
    30. res = c(res, cur);
    31. cur = 1;
    32. }
    33. else cur ++;
    34. }
    35. if(cur)res = c(res, cur);
    36. res = c(res, p[n - num]);
    37. cout << n - num << ' ' << res << '\n';
    38. }
    39. int main()
    40. {
    41. ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    42. int t;
    43. cin >> t;
    44. init();
    45. while(t --)
    46. {
    47. solve();
    48. }
    49. return 0;
    50. }
  • 相关阅读:
    hitTest的基本用法
    ts重点学习111-类的兼容性
    MySQL 事件调度
    【架构师技能篇】Worker初识
    小程序,公众号绑定微信开放平台帐号-UnionID机制
    flinksql postgres到mysql案例
    Cannot convert string value ‘UNIFIED_TEST_PLATFORM‘ to an enum value of type
    cortex-m3软件断点/单步执行的实现机制
    互联网Java工程师面试题·微服务篇·第一弹
    元宇宙持续升温,金蝶推出数字员工破圈而来
  • 原文地址:https://blog.csdn.net/m0_75087931/article/details/133282272