第一次参加 AtCoder 的比赛,感觉还挺简单。

比赛链接:https://atcoder.jp/contests/abc189

A - Slot

// Author : RioTian
// Time : 21/01/23
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
string s;
cin >> s;
if (s[0] == s[1] && s[1] == s[2])
cout << "Won\n";
else
cout << "Lost\n";
}

B - Alcoholic

高桥(大家都喜欢的高桥同学)要喝酒了,现在有n中酒,如果高桥同学喝酒的量大于 \(X \ ml\)则会喝酒离开酒席。那么请输出高桥是在第几个酒上喝醉了,如果没有喝醉请输出 -1

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n, v, p, x;
int sum = 0;
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
cin >> v >> p;
sum += v * p;
if (sum > x * 100) {
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
}

C - Mandarin

求最大连续序列和,但由于n比较小直接暴力即可。

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int a[N];
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i]; int ans = 0;
for (int l = 0; l < n; ++l) {
int x = a[l];
for (int r = l; r < n; ++r) {
x = min(x, a[r]);
ans = max(ans, x * (r - l + 1));
}
}
cout << ans << endl;
}

D - Logical Expression

如果 \(S_i\) 是 AND 则 opt 设为 true,在之后只要 \(f(S_1,...,S_N) = f(S_1,...,S_{N-1})\)

如歌 \(S_i\) 是 OR 则 opt 设为 false,需要 \(f(S_1,...,S_N) = 2^N + f(S_1,...,S_{N-1})\)

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100; ll dp[N][2];
bool opt[N];
string s; int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s; if (s[0] == 'A')
opt[i] = true;
else
opt[i] = false;
} dp[0][0] = dp[0][1] = 1;
for (int i = 1; i <= n; ++i) {
if (opt[i - 1]) {
dp[i][0] = 2 * dp[i - 1][0] + dp[i - 1][1];
dp[i][1] = dp[i - 1][1];
} else {
dp[i][0] = dp[i - 1][0];
dp[i][1] = 2 * dp[i - 1][1] + dp[i - 1][0];
}
} cout << dp[n][1] << endl;
}

E,F比赛时没做就先鸽一下了

AtCoder Beginner Contest 189 Personal Editorial的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  10. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. C/S结构用户界面设计

    C/S结构用户界面设计 [实验编号] 10003809547j  图形用户界面设计 [实验学时] 8学时 [实验环境] l 所需硬件环境为微机: l 所需软件环境为Microsoft Visual S ...

  2. 【UniApp】-uni-app-OptionAPI应用生命周期和页面生命周期

    前言 好,经过上个章节的介绍完毕之后,了解了一下 uni-app-修改组件主题和样式 那么了解完了uni-app-修改组件主题和样式之后,这篇文章来给大家介绍一下 uni-app-OptionAPI应 ...

  3. vertx的学习总结三

    一.event bus是什么 各个verticle的通信 二.point-to-point, request-reply, publish/subscribe 通过 the event bus 例题一 ...

  4. Git恢复删除的文件,一行命令就可以啦~

    情况一:删除或者修改了某个文件,但是没有add # 单个 git checkout filename # 多个 git checkout . 情况二:删除或者修改了某个文件,已经add,但是没有com ...

  5. RIPEMD加密算法:原理、应用与安全性

    一.引言 在信息时代,数据安全愈发受到重视,加密算法作为保障信息安全的关键技术,其性能和安全性备受关注.RIPEMD(RACE Integrity Primitives Evaluation Mess ...

  6. 报错信息如下:出现身份验证错误。要求的函数不受支持。可能是由于CredSSP加密数据库修正。

    微软官方已出补丁包:CVE-2018-0886 的 CredSSP 更新 Windows Server 2016, all editions.Windows Server 2012 R2 Standa ...

  7. 一个Tomcat 如何部署多个项目?附多种解决方案及详细步骤!

    此文源自一次多年前面试的面试题,民工哥将它总结出来分享给大家,希望对大家有所帮助,或者今后的面试中说不定会用的上. 首先,我们了解一下常见的Java Web服务器. Tomcat:由Apache组织提 ...

  8. 放弃JavaFx开发学习

    放弃JavaFx开发学习 一开始学学习JavaFx是想用java写个小游戏,后来学者JavaFx越来越深,发现坑也越来越多,不禁感叹:JavaFx果然是要抛弃的UI玩儿,UI开发还是用react na ...

  9. JavaFx之全局异常捕获(二十)

    JavaFx之全局异常捕获(二十) javafx开发时,我们有时候需要捕获未处理的异常.手动抛出的异常,在main方法中添加下面代码: public static void main(String[] ...

  10. 揭秘Spring事务失效场景分析与解决方案

    在Spring框架中,事务管理是一个核心功能,然而有时候会遇到事务失效的情况,这可能导致数据一致性问题.本文将深入探讨一些Spring事务失效的常见场景,并提供详细的例子以及解决方案. 1. 跨方法调 ...