結果

問題 No.2000 Distanced Characters
ユーザー 遭難者遭難者
提出日時 2022-06-25 23:37:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 4,997 ms
コンパイル使用メモリ 214,864 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 12:09:32
合計ジャッジ時間 6,018 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 11 ms
6,944 KB
testcase_09 AC 10 ms
6,940 KB
testcase_10 AC 10 ms
6,944 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
using namespace std;
using ll = long long;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define ALL(a) (a).begin(), (a).end()
int d[26][26];
bool a[26][26];
int t[26];
int main()
{
    string s;
    cin >> s;
    rep(i, 26) rep(j, 26) cin >> d[i][j], a[i][j] = true;
    rep(i, 26) t[i] = -1e9;
    const int n = s.length();
    rep(j, n)
    {
        const int c = s[j] - 'a';
        rep(i, 26) a[i][c] &= t[i] + d[i][c] <= j;
        t[c] = j;
    }
    rep(i, 26)
    {
        rep(j, 25) cout << (a[i][j] ? 'Y' : 'N') << " ";
        cout << (a[i][25] ? 'Y' : 'N') << endl;
    }
    return 0;
}
0