結果

問題 No.2000 Distanced Characters
ユーザー Nzt3Nzt3
提出日時 2022-09-24 23:22:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 206,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 00:39:01
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin>>S;
  int N=S.size();
  vector<vector<int>>D(26,vector<int>(26));
  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++)cin>>D[i][j];
  }
  array<int,26>Sd;
  for(int i=0;i<26;i++){
    Sd[i]=1e9;
  }
  vector<vector<char>>ans(26,vector<char>(26,'Y'));
  for(int i=N-1;i>=0;i--){
    int c=S[i]-'a';
    for(int j=0;j<26;j++){
      if(Sd[j]-i<D[c][j])ans[c][j]='N';
    }
    Sd[c]=i;
  }
  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++)cout<<ans[i][j]<<(j==25?'\n':' ');
  }
}
0