結果

問題 No.3114 0→1
コンテスト
ユーザー Alph(その辺の大学生A)
提出日時 2025-04-20 17:47:36
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
実行時間 -
コード長 820 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 182 ms
コンパイル使用メモリ 41,924 KB
最終ジャッジ日時 2026-02-22 13:33:57
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other RE * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:10:9: warning: '_' redefined
   10 | #define _(x,Y) ((x)?1:0)
      |         ^
main.c:6:9: note: this is the location of the previous definition
    6 | #define _(X,Y) ((X)<(Y)?(X):(Y))
      |         ^

ソースコード

diff #
raw source code

#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