結果

問題 No.3114 0→1
ユーザー Alph(その辺の大学生A)
提出日時 2025-04-20 17:47:36
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 820 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 26,752 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-20 17:47:41
合計ジャッジ時間 5,304 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other RE * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:10: warning: "_" redefined
   10 | #define _(x,Y) ((x)?1:0)
      | 
main.c:6: note: this is the location of the previous definition
    6 | #define _(X,Y) ((X)<(Y)?(X):(Y))
      | 
main.c: In function ‘main’:
main.c:27:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     scanf("%d%s",&l,d);
      |     ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define Z(z,Y) for((z)=0;(z)<(Y);(z)++)
#define _(X,Y) ((X)<(Y)?(X):(Y))
#define oO(O0,oO0,O00) for((O0)=1;(O0)<(O00)-(oO0)+1;(O0)++)
#define OO(O0,O00,O000) for((O0)=O00;(O0)<(O000);(O0)++)
#define $ malloc
#define _(x,Y) ((x)?1:0)

int OOO(char* o0, int OO0, int o00) {
    int o = (o00+1)/2, O = OO0+o-1, i, j, x=0, w=0;
    char*S=(char*)$((O)*sizeof(char)),*K=(char*)$((O)*sizeof(char));
    Z(i,o-1)S[i]=1;
    OO(i,o-1,O)S[i]=(o0[i-o+1]=='1')?1:0;
    Z(i,O)K[i]=S[i];
    Z(i,o00)w+=(S[i])?1:0;
    if(w<o)S[o00-1]=1,x++,w++;
    oO(i,o00,O)w-=(S[i-1])?1:0,w+=(S[i+o00-1])?1:0,w<o?(S[i+o00-1]=1,x++,w++):0;
    free(S),free(K);
    return x;
}

int main(){
    int l;char d[1001];
    scanf("%d%s",&l,d);
    printf("%d\n",OOO(d,l,3));
    return 0;
}
0