結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー sapphire__15sapphire__15
提出日時 2022-08-13 17:00:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,019 bytes
コンパイル時間 1,090 ms
コンパイル使用メモリ 93,740 KB
実行使用メモリ 44,820 KB
最終ジャッジ日時 2023-09-08 20:03:52
合計ジャッジ時間 31,400 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,388 KB
testcase_02 AC 451 ms
26,496 KB
testcase_03 AC 501 ms
32,560 KB
testcase_04 AC 501 ms
26,676 KB
testcase_05 AC 412 ms
20,580 KB
testcase_06 AC 551 ms
28,288 KB
testcase_07 AC 183 ms
20,416 KB
testcase_08 AC 219 ms
11,720 KB
testcase_09 AC 376 ms
30,728 KB
testcase_10 AC 272 ms
14,576 KB
testcase_11 AC 162 ms
15,240 KB
testcase_12 AC 364 ms
23,460 KB
testcase_13 AC 503 ms
36,488 KB
testcase_14 AC 447 ms
22,924 KB
testcase_15 AC 604 ms
30,452 KB
testcase_16 AC 705 ms
40,708 KB
testcase_17 AC 135 ms
16,028 KB
testcase_18 AC 285 ms
26,480 KB
testcase_19 AC 297 ms
18,316 KB
testcase_20 AC 549 ms
38,916 KB
testcase_21 AC 377 ms
17,792 KB
testcase_22 AC 724 ms
44,708 KB
testcase_23 AC 725 ms
44,560 KB
testcase_24 AC 727 ms
44,652 KB
testcase_25 AC 727 ms
44,612 KB
testcase_26 AC 753 ms
44,652 KB
testcase_27 AC 727 ms
44,708 KB
testcase_28 AC 720 ms
44,340 KB
testcase_29 AC 727 ms
44,604 KB
testcase_30 AC 718 ms
44,600 KB
testcase_31 AC 728 ms
44,648 KB
testcase_32 AC 740 ms
44,652 KB
testcase_33 AC 729 ms
44,820 KB
testcase_34 AC 738 ms
44,716 KB
testcase_35 AC 727 ms
44,704 KB
testcase_36 AC 731 ms
44,600 KB
testcase_37 AC 716 ms
44,816 KB
testcase_38 AC 731 ms
44,656 KB
testcase_39 AC 728 ms
44,568 KB
testcase_40 AC 730 ms
44,572 KB
testcase_41 AC 723 ms
44,604 KB
testcase_42 TLE -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

bool check(const string &s, const string &t) {
    static const int ALL_SAME = -10;
    static const int SWAPED   = -11;
    if(s.size() != t.size()) return false;
    int prv = ALL_SAME;
    for(int i = 0; i < (int)s.size(); i++) {
        if(s[i] != t[i]) {
            if(prv == ALL_SAME) prv = i;
            else if(prv == i-1) prv = SWAPED;
            else return false;
        }
    }
    return prv < 0;
}

int main() {
    int n; cin >> n;
    vector<string> s(n);
    for(auto &i : s) cin >> i;
    vector<bool> ans(n);
    map<vector<int>, vector<string>> mp;
    for(int i = 0; i < n; i++) {
        vector<int> cnt(26);
        for(auto &j : s[i]) cnt[j-'a']++;
        for(auto &t : mp[cnt]) {
            if(check(s[i], t)) {
                ans[i] = true;
                break;
            }
        }
        mp[cnt].emplace_back(s[i]);
    }
    for(auto &&i : ans) cout << ((i) ? "Yes" : "No") << endl;
}
0