1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

AtCoder Beginner Contest 403にバーチャル参加しました。

概略

  • ABC403にバーチャル参加した
  • 時間が無くて(Daily Trainingも参加している)2問のみ
  • B問題が250点問題で難度アップ

A - Odd Position Sum

奇数番目の数値を足し合わせるだけの簡単なお仕事です。
ただし、ループの添字を0からにしている方は注意が必要な、AtCoderのA問題にふさわしい罠が仕掛けられています。

A.cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (i % 2 == 0) ans += a;
  }
  cout << ans << endl;
  return 0;
}

B - Four Hidden

文字列$T$の中に文字列$U$が含まれているかを1文字ずつずらして愚直に検索すればOKです。
なお?はいわゆるワイルドカードなのでその点には注意が必要です。

ans = false;の後にbreak;を入れれば良かったかなーと反省。
まあいいか、結果は1msだし。

B.cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
  string T, U;
  cin >> T >> U;
  for (int i = 0; i <= (int)(T.size() - U.size()); i++) {
    bool ans = true;
    for (int j = 0; j < (int)(U.size()); j++) {
      if (T[i + j] != '?' && T[i + j] != U[j]) ans = false;
    }
    if (ans) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

最後に

今回は疲れていて(流石に私用で3日間空けた後帰宅したその日は年齢的に無理)不参加でした。
今もまだ疲れが完全に取れていません。うーん、これが50歳というやつかあ……。

なお次回(5月3日)は是非参加したい所存です。

課題

  • まだ読み終えてない『問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本』(アルゴ数学本)を読み進める
  • アルゴ数学本の問題を解く(AtCoderでこの本専用のコンテストがあって問題を解くことができる)
  • 高校数学の書籍(数冊所持)を読む
  • アルゴ式を進める。まずはPython入門・基礎編を全クリアーする

その他

『競技プログラミングの鉄則』購入しました。アルゴ数学本は電子書籍だったのですが、こちらは固定レイアウト方式とのことだったので、紙書籍で購入しました。
なおアルゴ数学本を読み終えていないので、まだ読んでいません。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?