結果

問題 No.2000 Distanced Characters
ユーザー RuiRui
提出日時 2022-12-13 22:22:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 1,289 bytes
コンパイル時間 4,098 ms
コンパイル使用メモリ 225,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 06:01:43
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 22 ms
5,376 KB
testcase_09 AC 239 ms
5,376 KB
testcase_10 AC 128 ms
5,376 KB
testcase_11 AC 34 ms
5,376 KB
testcase_12 AC 61 ms
5,376 KB
testcase_13 AC 54 ms
5,376 KB
testcase_14 AC 62 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef modint998244353 mint;
const int MOD = 1000000007;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;
    vector<vector<int>> a(26, vector<int>(26));
    rep(i, 26) rep(j, 26) cin >> a[i][j];

    vector<vector<int>> vec(26);
    rep(i, s.size()) vec[s[i] - 'a'].push_back(i);

    rep(i, 26){
        rep(j, 26){
            bool b = true;
            rep(k, vec[i].size()){
                if(vec[j].size() == 0 || vec[j][vec[j].size() - 1] <= vec[i][k]) continue;
                auto it = upper_bound(all(vec[j]), vec[i][k]);
                if(vec[i][k] + a[i][j] > vec[j][it - vec[j].begin()]) b = false;
            }
            if(b) cout << "Y" << ' ';
            else cout << "N" << ' ';
        }
        cout << endl;
    }

    return 0;
}
0