結果

問題 No.2000 Distanced Characters
ユーザー umezoumezo
提出日時 2022-07-08 22:18:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 199,248 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 21:57:37
合計ジャッジ時間 2,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int D[26][26];
int A[26][26];
const int INF=1e9; 
int B[26];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  string s;
  cin>>s;
  int n=s.size();
  
  rep(i,26) rep(j,26){
    cin>>D[i][j];
    A[i][j]=INF;
  }
  rep(i,26) B[i]=-1;
  
  rep(i,n){
    int a=s[i]-'a';
    rep(j,26){
      if(B[j]==-1) continue;
      A[j][a]=min(A[j][a],i-B[j]);
    }
    B[a]=i;
  }
  
  rep(i,26){
    rep(j,26){
      if(j) cout<<" ";
      if(D[i][j]<=A[i][j]) cout<<'Y';
      else cout<<'N';
    }
    cout<<endl;
  }

  return 0;
}
0