結果

問題 No.2000 Distanced Characters
ユーザー RubikunRubikun
提出日時 2022-07-08 21:24:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,405 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 203,572 KB
実行使用メモリ 4,672 KB
最終ジャッジ日時 2023-08-27 20:45:40
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 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,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 57 ms
4,672 KB
testcase_10 AC 28 ms
4,384 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 15 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
    }
}
0