結果

問題 No.3435 [Cherry 8th Tune *] 何回 LOVE SONG を書き換えただろうか?
コンテスト
ユーザー abc864197532
提出日時 2026-01-23 21:27:36
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 287 ms / 3,000 ms
コード長 1,552 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,407 ms
コンパイル使用メモリ 345,944 KB
実行使用メモリ 51,072 KB
最終ジャッジ日時 2026-01-23 21:27:54
合計ジャッジ時間 14,559 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
#ifdef Doludu
template <typename T>
ostream& operator << (ostream &o, vector <T> vec) {
    o << "{"; int f = 0;
    for (T i : vec) o << (f++ ? " " : "") << i;
    return o << "}";
}
void bug__(int c, auto ...a) {
    cerr << "\e[1;" << c << "m";
    (..., (cerr << a << " "));
    cerr << "\e[0m" << endl;
}
#define bug_(c, x...) bug__(c, __LINE__, "[" + string(#x) + "]", x)
#define bug(x...) bug_(32, x)
#define bugv(x...) bug_(36, vector(x))
#define safe bug_(33, "safe")
#else
#define bug(x...) void(0)
#define bugv(x...) void(0)
#define safe void(0)
#endif
const int mod = 998244353, N = 1 << 20;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s; cin >> s;
    int k = sz(s);
    vector cost(k, vector(k, 0ll));
    for (int i = 0; i < k; ++i) for (int j = 0; j < k; ++j) cin >> cost[i][j];
    int n, m;
    cin >> n >> m;
    vector <vector <int>> a(n);
    vector cnt(m, vector(k, 0));
    for (int i = 0; i < n; ++i) {
        string t; cin >> t;
        for (int j = 0; j < m; ++j) {
            a[i].pb(find(all(s), t[j]) - s.begin());
            cnt[j][a[i][j]]++;
        }
    }
    for (int i = 0; i < n; ++i) {
        ll ans = 0;
        for (int j = 0; j < m; ++j) {
            for (int ii = 0; ii < k; ++ii) {
                ans += cost[a[i][j]][ii] * cnt[j][ii];
            }
        }
        cout << ans << "\n";
    }
}
0