結果

問題 No.501 穴と文字列
ユーザー LayCurseLayCurse
提出日時 2017-04-08 00:12:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 143,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 07:13:32
合計ジャッジ時間 2,140 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  char res[60000];
  int D, N, i, r;
  rd(N);
  rd(D);
  r = N;
  for(i=0;i<N;i++){
    if(D && D != 2*r){
      res[i] = 'A';
      r--;
      D--;
    }
    else if(D){
      res[i] = 'B';
      r--;
      D-=2;
    }
    else{
      res[i] = 'C';
      r--;
    }
  }
  res[N] = '\0';
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170407-2 [beta]

// --- original code ---
// {
//   int N, D;
//   int i, r;
//   char res[60000];
//   
//   rd(N, D);
// 
//   r = N;
//   rep(i,N){
//     if(D && D != 2*r){
//       res[i] = 'A';
//       r--; D--;
//     } else if(D){
//       res[i] = 'B';
//       r--; D-=2;
//     } else {
//       res[i] = 'C';
//       r--;
//     }
//   }
// 
//   res[N] = '\0';
//   wt(res);
// }
0