結果

問題 No.501 穴と文字列
ユーザー vjudge1
提出日時 2025-06-24 17:57:08
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 4,522 ms
コンパイル使用メモリ 168,908 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-24 17:57:15
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,d;
bool check(int x,int k){
    return 2*(n-x)>=d-k&&d-k>=0;
}
signed main(){
    // freopen("hole.in","r",stdin);
    // freopen("hole.out","w",stdout);
    cin>>n>>d;
    for (int i=1;i<n;i++){
        if(check(i,1)){
            cout<<'A';
            d--;
        }
        else if(check(i,2)){
            cout<<'B';
            d-=2;
        }
        else{
            cout<<'C';
        }
    }
    if(d==0) cout<<'C';
    else if(d==1) cout<<'A';
    else cout<<'B';
    return 0;
}
0