結果

問題 No.2000 Distanced Characters
ユーザー atjh16atjh16
提出日時 2022-08-11 22:35:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 204,696 KB
実行使用メモリ 4,872 KB
最終ジャッジ日時 2023-10-22 04:03:38
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 8 ms
4,572 KB
testcase_09 AC 325 ms
4,872 KB
testcase_10 AC 157 ms
4,720 KB
testcase_11 AC 44 ms
4,572 KB
testcase_12 AC 103 ms
4,348 KB
testcase_13 AC 92 ms
4,348 KB
testcase_14 AC 53 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

string s;
int d[26][26];
vector<int> e[26];

int main() {    
    cin >> s;

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> d[i][j];
        }
    }

    for (int i = 0; i < s.size(); i++) {
        int u = s[i] - 'a';
        e[u].push_back(i + 1);
    }
    
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++) {
            bool f = 1;

            for (int k = 0; k < e[i].size(); k++) {
                if (upper_bound(e[j].begin(), e[j].end(), e[i][k]) == e[j].end())
                    break;
                else if (*upper_bound(e[j].begin(), e[j].end(), e[i][k]) - e[i][k] < d[i][j]) {
                    f = 0;
                    break;
                }
            }

            if (f)
                cout << "Y";
            else
                cout << "N";

            if (j < 25)
                cout << " ";
        }
        cout << endl;
    }
}
0