結果
| 問題 | 
                            No.2768 Password Crack
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-01 12:34:13 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 878 bytes | 
| コンパイル時間 | 984 ms | 
| コンパイル使用メモリ | 101,660 KB | 
| 実行使用メモリ | 25,580 KB | 
| 平均クエリ数 | 1785.17 | 
| 最終ジャッジ日時 | 2024-12-21 19:16:21 | 
| 合計ジャッジ時間 | 9,330 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 1 WA * 28 | 
コンパイルメッセージ
In function 'constexpr bool chmax(T&, const T&) [with T = int]',
    inlined from 'int main()' at main.cpp:18:21:
main.cpp:5:77: warning: 'cnt' may be used uninitialized [-Wmaybe-uninitialized]
    5 | template <class T> constexpr inline bool chmax(T& a, const T& b) noexcept { if(a < b){ a = b; return true; } return false; }
      |                                                                             ^~
main.cpp: In function 'int main()':
main.cpp:7:12: note: 'cnt' was declared here
    7 |     int n, cnt;
      |            ^~~
main.cpp:26:14: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
   26 |         s[i] = c;
main.cpp:12:14: note: 'c' was declared here
   12 |         char c;
      |              ^
            
            ソースコード
#include <iostream>
#include <ranges>
constexpr int INF = 1 << 30;
template <class T> constexpr inline bool chmin(T& a, const T& b) noexcept { if(a > b){ a = b; return true; } return false; }
template <class T> constexpr inline bool chmax(T& a, const T& b) noexcept { if(a < b){ a = b; return true; } return false; }
int main() {
    int n, cnt;
    std::cin >> n;
    std::string s(n, 'a');
    for(const auto i: std::views::iota(0, n)) {
        int chk = INF;
        char c;
        for(const auto j: std::views::iota(0, 25)) {
            s[i] = 'a' + j;
            std::cout << "? " + s + "\n";
            int now;
            std::cin >> now;
            if(chmax(cnt, now)) {
                c = 'a' + j;
            }
            chmin(chk, now);
        }
        if(!chk) {
            c = 'z';
        }
        s[i] = c;
    }
    std::cout << "! " + s << '\n';
}