結果

問題 No.2997 Making YuzuKizu
ユーザー tnakao0123
提出日時 2024-12-30 16:23:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 55,536 KB
最終ジャッジ日時 2025-02-26 17:15:08
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2997.cc:  No.2997 Making YuzuKizu - yukicoder
 */

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 1000000;
const int K = 3;
const char ts[K][16] = {"yukari", "akari", "yuzukizu"};
const int INF = 1 << 30;

/* typedef */

using vi = vector<int>;

/* global variables */

char s[MAX_N + 4];

/* subroutines */

vi s2cv(const char t[]) {
  vi cv(26, 0);
  for (int i = 0; t[i]; i++) cv[t[i] - 'a']++;
  return cv;
}

int divcv(vi &cv0, vi &cv1) {
  int d = INF;
  for (int i = 0; i < 26; i++)
    if (cv1[i]) d = min(d, cv0[i] / cv1[i]);
  return d;
}

/* main */

int main() {
  scanf("%s", s);
  vi scv = s2cv(s);

  for (int i = 0; i < K; i++) {
    vi tcv = s2cv(ts[i]);
    int d = divcv(scv, tcv);
    
    printf("%d%c", d, (i + 1 < K) ? ' ' : '\n');
  }
  
  return 0;
}
0