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?

はじめに

今週は私用でABC403に参加できそうにないので、代わりに昨日のAtCoder Daily Trainingの結果を公開してみます。
難易度はEASYです。まだまだ灰色コーダーですし。
Xのハッシュタグ:#ADT_20250424_1

AtCoder Daily Trainingとは?

  • AtCoder Beginner Contest(ABC)に出題された過去問を1時間で解くトレーニング
  • (現在は)火水木曜の夕方〜夜(1日3回)に行われている
  • 難易度選択が可能だが、同時刻の複数難易度に同時参加することはできない
  • レートは変化しないし、記録にも残らない。あくまでもトレーニング
  • 詳細は上のリンク先を参照のこと

A - Pawn on a Grid

#の数を数えるだけのかんたんなお仕事です。
全探索で行いました。

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

int main() {
  int h, w, ans = 0;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < w; j++) {
      if (s[j] == '#') ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

B - Tires

末尾が"er"か"ist"の文字列を与えられるので、末尾の"er""ist"を返す問題です。

"er"か"ist"なので、末尾が"er"の場合に"er"と答えましたが、今考えれば文字列全体をreverseで反転させて"re"から始まることを確認すれば末尾が"er"ということなんですよね……。

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

int main() {
  string s;
  cin >> s;
  if (s.find("er") == s.size() - 2) cout << "er" << endl;
  else cout << "ist" << endl;
  return 0;
}

C - Who is missing?

カードデッキから1枚抜き取られたカードを判定する問題です。
今回はmapを活用しました。
カードを受け取る際のループ回数が$4N-1$なのは注意点です。

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

int main() {
  int N;
  cin >> N;
  map<int, int> a;
  for (int i = 0; i < 4 * N - 1; i++) {
    int ain;
    cin >> ain;
    a[ain] += 1;
  }
  for (int i = 1; i <= N; i++) {
    if (a[i] == 3) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

D問題以降

私用のため時間がなくて解けませんでした。

まとめ

  • 速度はまだまだ遅い
  • たまに理解不能な問題がある
  • 圧倒的数理素養不足
  • 要勉強・トレーニング

その他

アルゴ式はじめました。

最後に

ここまで読んでいただき、ありがとうございました。
では、私用に行って参ります。

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?