結果
問題 | No.2000 Distanced Characters |
ユーザー | Rubikun |
提出日時 | 2022-07-08 21:24:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 1,405 bytes |
コンパイル時間 | 2,397 ms |
コンパイル使用メモリ | 199,768 KB |
最終ジャッジ日時 | 2025-01-30 05:16:00 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=1000000007,MAX=1005,INF=1<<30; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); string S;cin>>S; vector<vector<int>> pos(26); for(int i=0;i<si(S);i++){ pos[S[i]-'a'].push_back(i); } vector<vector<int>> A(26,vector<int>(26)); for(int i=0;i<26;i++){ for(int j=0;j<26;j++){ cin>>A[i][j]; } } for(int i=0;i<26;i++){ for(int j=0;j<26;j++){ if(si(pos[i])==0||si(pos[j])==0){ cout<<"Y "; }else{ int b=0; bool ok=true; for(int a=0;a<si(pos[i]);a++){ while(b<si(pos[j])&&pos[i][a]>=pos[j][b]) b++; if(b==si(pos[j])) break; if(pos[j][b]-pos[i][a]<A[i][j]) ok=false; } if(ok) cout<<"Y "; else cout<<"N "; } } cout<<"\n"; } }