結果

問題 No.3061 Cut and Maximums
コンテスト
ユーザー vjudge1
提出日時 2026-03-23 11:24:55
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,112 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,019 ms
コンパイル使用メモリ 165,328 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-23 11:24:59
合計ジャッジ時間 3,552 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    string S;
    getline(cin, S);
    int n = S.size();
    
    for (int p : {0, 1}) {
        vector<bool> B(26, false);
        for (int i = 0; i < n; ++i) {
            if ((i + 1) % 2!= p && islower(S[i])) {
                B[S[i] - 'a'] = true;
            }
        }
        
        vector<int> non_blanks;
        for (int i = 0; i < n; ++i) {
            if ((i + 1) % 2 == p && islower(S[i]) &&!B[S[i] - 'a']) {
                non_blanks.push_back(i + 1);
            }
        }
        
        if (non_blanks.empty()) continue;
        
        int first = non_blanks[0];
        int last = non_blanks.back();
        int expected = (last - first) / 2 + 1;
        
        if (non_blanks.size()!= expected) continue;
        
        if (last > first) {
            cout << "Yes\n";
            return 0;
        } else {
            if (first + 1 <= n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    
    cout << "NO\n";
    return 0;
}
0