結果

問題 No.1132 凸凹
ユーザー iiljjiiljj
提出日時 2020-10-07 00:44:01
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 4,828 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 31,460 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 09:01:19
合計ジャッジ時間 1,733 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,380 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 0 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 0 ms
4,376 KB
testcase_26 AC 0 ms
4,376 KB
testcase_27 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:6:15: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    6 |         tmp = getchar_unlocked();                                                                                      \
      |               ^~~~~~~~~~~~~~~~
main.c:38:5: 備考: in expansion of macro ‘rd_int’
   38 |     rd_int(var, tmp, sign);
      |     ^~~~~~
main.c:50:5: 備考: in expansion of macro ‘rd_int_’
   50 |     rd_int_(a, tmp, sign);
      |     ^~~~~~~
main.c:16:15: 警告: 関数 ‘getc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   16 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:38:5: 備考: in expansion of macro ‘rd_int’
   38 |     rd_int(var, tmp, sign);
      |     ^~~~~~
main.c:50:5: 備考: in expansion of macro ‘rd_int_’
   50 |     rd_int_(a, tmp, sign);
      |     ^~~~~~~
main.c:33:15: 警告: 関数 ‘putc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   33 |     if (sign) putc_unlocked('-', stdout);                                                                              \
      |               ^~~~~~~~~~~~~
main.c:42:5: 備考: in expansion of macro ‘wt_int’
   42 |     wt_int(var, buf, ptr, sign);
      |     ^~~~~~
main.c:65:5: 備考: in expansion of macro ‘wt_int_’
   65 |     wt_int_(ma, buf, ptr, sign);
      |     ^~~~~~~

ソースコード

diff #

#include <stdio.h>

// int tmp, var = 0, sign = 0; を先に宣言する
#define rd_int(var, tmp, sign)                                                                                         \
    for (;;) {                                                                                                         \
        tmp = getchar_unlocked();                                                                                      \
        if (tmp == '-') {                                                                                              \
            sign = 1;                                                                                                  \
            break;                                                                                                     \
        } else if ('0' <= tmp && tmp <= '9') {                                                                         \
            var = tmp - '0';                                                                                           \
            break;                                                                                                     \
        }                                                                                                              \
    }                                                                                                                  \
    for (;;) {                                                                                                         \
        tmp = getc_unlocked(stdin);                                                                                    \
        if (tmp < '0' || tmp > '9') break;                                                                             \
        var = var * 10 + tmp - '0';                                                                                    \
    }                                                                                                                  \
    if (sign) var = -var;

// char buf[9]; int ptr = 0, sign = 0; を先に宣言する
#define wt_int(var, buf, ptr, sign)                                                                                    \
    if (var < 0) {                                                                                                     \
        sign = 1;                                                                                                      \
        var = -var;                                                                                                    \
    }                                                                                                                  \
    while (var) {                                                                                                      \
        buf[ptr++] = var % 10;                                                                                         \
        var /= 10;                                                                                                     \
    }                                                                                                                  \
    if (!ptr) buf[ptr++] = 0;                                                                                          \
    if (sign) putc_unlocked('-', stdout);                                                                              \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

#define rd_int_(var, tmp, sign)                                                                                        \
    sign = 0;                                                                                                          \
    rd_int(var, tmp, sign);

#define wt_int_(var, buf, ptr, sign)                                                                                   \
    ptr = sign = 0;                                                                                                    \
    wt_int(var, buf, ptr, sign);

#define f(x, a, b, c, d) (a * x * x * x + b * x * x + c * x + d)

int main() {
    int a = 0, b = 0, c = 0, d = 0, p = 0, q = 0, tmp, sign, ptr;
    char buf[10];

    rd_int_(a, tmp, sign);
    rd_int_(b, tmp, sign);
    rd_int_(c, tmp, sign);
    rd_int_(d, tmp, sign);
    rd_int_(p, tmp, sign);
    rd_int_(q, tmp, sign);

    int y = f(p, a, b, c, d);
    int mi = y, ma = y, xmi = p, xma = p;
    for (int x = p + 1; x <= q; ++x) {
        y = f(x, a, b, c, d);
        if (y < mi) mi = y, xmi = x;
        if (y > ma) ma = y, xma = x;
    }

    wt_int_(ma, buf, ptr, sign);
    putc_unlocked(' ', stdout);
    wt_int_(xma, buf, ptr, sign);
    putc_unlocked(' ', stdout);
    wt_int_(mi, buf, ptr, sign);
    putc_unlocked(' ', stdout);
    wt_int_(xmi, buf, ptr, sign);

    return 0;
}
0