結果
| 問題 | 
                            No.2000 Distanced Characters
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-08-03 21:10:27 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 224 ms / 2,000 ms | 
| コード長 | 1,199 bytes | 
| コンパイル時間 | 4,183 ms | 
| コンパイル使用メモリ | 253,444 KB | 
| 最終ジャッジ日時 | 2025-01-30 17:23:14 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 13 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };
int main() {
  string s;
  cin >> s;
  vector d(26, vector<int>(26));
  rep(i,26)rep(j,26) cin >> d[i][j];
  vector<int> pos[26];
  rep(i,s.size()) {
    pos[s[i]-'a'].pb(i);
  }
  const int INF = 1001001001;
  vector dmin(26,vector<int>(26, INF));
  rep(i,26)rep(j,26) {
    if (i == j) {
      rep(k,(int)pos[i].size()-1) {
        chmin(dmin[i][i], pos[i][k+1]-pos[i][k]);
      }
    } else {
      for (auto x : pos[i]) {
        auto it = lower_bound(all(pos[j]), x);
        if (it != pos[j].end()) chmin(dmin[i][j], abs(x-*it));
      }
    }
  }
  rep(i,26){ 
    rep(j,26) {
      if (d[i][j] <= dmin[i][j]) cout << "Y" << " ";
      else cout << "N" << " ";
    }
    cout << endl;
  } 
  return 0;
}