Codeforces Round 929 (Div. 3)

A. Turtle Puzzle: Rearrange and Negate 因为可以任意排列这个数组,并将一段区间内的数乘 $-1$,我们可以排序后把所有负数变为正数,即可 $code:$ void solve() { int n; std::cin >> n; int ans = 0; for(int i = 0, x; i < n; i ++ ) { std::cin >> x; ans += std::abs(x); } std::cout << ans << '\n'; } B. Turtle Math: Fast Three Task 分类讨论,$\sum_{i=1}^na_i\mod 3$ 等于 $0$ 的话不需要操作,等于 $1$ 就看有...

2024-02-28 · 3 分钟 · shift

Educational Codeforces Round 161 (Rated for Div. 2) A-E

A. Tricky Template 我们对每个位置 $i$ 来看,只要 $a_i == c_i \ or \ b_i == c_i$​ ,那么就会使其不成立, 如果是整个字符串呢,那么就是,那么就需要每个位置都成立才能使其不成立,于是遍历判断一下即可 $code:$ void solve() { int n; std::cin >> n; std::string a, b, c; std::cin >> a >> b >> c; int ok = 0; for(int i = 0; i < n; i ++ ) { if(a[i] != c[i] && b[i] != c[i]) { ok = 1; } } std::cout << (ok ? "YES" : "NO")...

2024-02-06 · 2 分钟 · shift