#include using namespace std; using ll=long long; using Pa=pair; using Vll=vector; using VVll=vector; using Vb=vector; using VVb=vector>; using Vs=vector; using VVs =vector>; using Vc=vector; using VVc =vector>; const ll MOD=1000000007; const ll INF=(ll)1<<60;// 10^18 < 1<<60 = 1152921504606846976 // VVll G(N+1,Vll(0)); // vector event; event.emplace_back(a,b); // 以下の関数 oi:エラー出力 OI:正出力 OIV:1次元vector正出力 OIVV:2次元vector正出力 template bool chmax(t&a,u b){if(a bool chmin(t&a,u b){if(bvoid oi(Head&& head,Tail&&... tail){if(sizeof...(tail)!=0){cerr<void OI(Head&& head,Tail&&... tail){if(sizeof...(tail)!=0){cout< void OIV(T &a){if(a.empty()){cout<<"\n"; return;} for(ll i00=0;i00<(a).size();i00++){if(a[i00]==(ll)1<<60){cout<<"I";} else{cout< void OIVV(T &a){if(a.empty()){cout<<"\n"; return;} for(ll i00=0;i00<(a).size();i00++){for(ll j00=0;j00<(a[i00]).size();j00++){if(a[i00][j00]==(ll)1<<60){cout<<"I";} else{cout<>S; ll N=S.size(); ll R=26; VVll D(R,Vll(R,0)); FOR(i,0,R) FOR(j,0,R) cin>>D[i][j]; VVll P(N+1,Vll(26,-INF));// P[i][j]:=i-1番目までにアルファベットj 0~25があるならjのindexのmax FOR(i,0,N-1){ ll a=S[i]-'a'; FOR(j,0,R){ if(j==a) P[i+1][j]=i; else{ P[i+1][j]=P[i][j]; } } } VVc X(R, Vc(R,'Y')); FOR(j,0,N){ ll b=S[j]-'a'; FOR(a,0,R){ ll i=P[j][a]; if(i==-INF) continue; if(i+D[a][b]>j) X[a][b]='N'; } } OIVV(X); return 0; }