1499A. Domino on Windowsill

题意:给定一个 Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C) - 图1 的空间,Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C) - 图2#card=math&code=k1%E3%80%81k2%20%E8%A1%8C%E8%A6%81%E8%AE%BE%E7%BD%AE%E4%B8%BA%E7%99%BD%E8%89%B2%282%20%5Ctimes%201%29) 然后其他的设置为黑色

思路:为了满足条件需要判断一下白色和黑色的方块是否足够。

  1. int main() {
  2. ios_base::sync_with_stdio(false), cin.tie(0);
  3. int _ = 1;
  4. for (cin >> _; _--;) {
  5. int n, k1, k2, w, b;
  6. cin >> n >> k1 >> k2 >> w >> b;
  7. if (2 * w <= k1 + k2 and 2 * b <= 2 * n - k1 - k2) cout << "YES\n";
  8. else
  9. cout << "NO\n";
  10. }
  11. return 0;
  12. }

1499B. Binary Removals

找下前缀的 0和后缀的 1的个数进行比较

  1. int main() {
  2. ios_base::sync_with_stdio(false), cin.tie(0);
  3. int _ = 1;
  4. for (cin >> _; _--;) {
  5. string s;
  6. cin >> s;
  7. int L = 0, R = s.size() - 1;
  8. while (L < s.size() and (s[L] == '0' or (L == 0 or s[L - 1] == '0')))
  9. L++;
  10. while (R >= 0 and
  11. (s[R] == '1' or (R == (int)s.size() - 1 or s[R + 1] == '1')))
  12. R--;
  13. if (L >= R) cout << "YES\n";
  14. else
  15. cout << "NO\n";
  16. }
  17. return 0;
  18. }

学习高 Rank 的大佬写法

  1. int main() {
  2. ios_base::sync_with_stdio(false), cin.tie(0);
  3. int _ = 1;
  4. for (cin >> _; _--;) {
  5. string s;
  6. cin >> s;
  7. int i = s.find("11");
  8. int j = s.rfind("00");
  9. cout << (i != -1 && j != -1 && i < j ? "NO" : "YES") << endl;
  10. }
  11. return 0;
  12. }

1499C. Minimum Grid Path

  1. using ll = long long;
  2. int main() {
  3. ios_base::sync_with_stdio(false), cin.tie(0);
  4. int _ = 1;
  5. for (cin >> _; _--;) {
  6. int n;
  7. cin >> n;
  8. vector<int> c(n);
  9. ll ans = LLONG_MAX;
  10. ll mi[2] = {(ll)1E13, (ll)1E13}, sm[2] = {0, 0}, cnt[2] = {0, 0};
  11. for (int i = 0; i < n; ++i) {
  12. ll c;
  13. cin >> c;
  14. mi[i & 1] = min(mi[i & 1], c);
  15. cnt[i & 1] += 1;
  16. sm[i & 1] += c;
  17. ans = min(ans, mi[0] * (n - cnt[0]) + sm[0] + mi[1] * (n - cnt[1]) +
  18. sm[1]);
  19. }
  20. cout << ans << "\n";
  21. }
  22. return 0;
  23. }