結果

問題 No.2142 Segment Zero
ユーザー WangzyyWangzyy
提出日時 2023-04-27 16:38:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 426 ms / 2,000 ms
コード長 1,025 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 188,524 KB
実行使用メモリ 53,760 KB
最終ジャッジ日時 2024-04-28 08:35:17
合計ジャッジ時間 10,077 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,008 KB
testcase_01 AC 426 ms
53,628 KB
testcase_02 AC 5 ms
11,072 KB
testcase_03 AC 6 ms
11,020 KB
testcase_04 AC 404 ms
53,632 KB
testcase_05 AC 394 ms
53,760 KB
testcase_06 AC 5 ms
11,136 KB
testcase_07 AC 72 ms
23,080 KB
testcase_08 AC 392 ms
53,632 KB
testcase_09 AC 183 ms
36,464 KB
testcase_10 AC 395 ms
53,760 KB
testcase_11 AC 384 ms
53,692 KB
testcase_12 AC 381 ms
53,636 KB
testcase_13 AC 397 ms
53,636 KB
testcase_14 AC 400 ms
53,760 KB
testcase_15 AC 381 ms
53,628 KB
testcase_16 AC 383 ms
53,632 KB
testcase_17 AC 328 ms
50,288 KB
testcase_18 AC 11 ms
12,416 KB
testcase_19 AC 31 ms
16,772 KB
testcase_20 AC 162 ms
34,032 KB
testcase_21 AC 127 ms
30,416 KB
testcase_22 AC 293 ms
50,288 KB
testcase_23 AC 50 ms
20,608 KB
testcase_24 AC 78 ms
23,848 KB
testcase_25 AC 50 ms
20,488 KB
testcase_26 AC 164 ms
33,136 KB
testcase_27 AC 74 ms
22,948 KB
testcase_28 AC 136 ms
31,216 KB
testcase_29 AC 156 ms
33,904 KB
testcase_30 AC 292 ms
50,160 KB
testcase_31 AC 10 ms
12,288 KB
testcase_32 AC 59 ms
21,412 KB
testcase_33 AC 31 ms
16,256 KB
testcase_34 AC 64 ms
21,668 KB
testcase_35 AC 388 ms
52,864 KB
testcase_36 AC 56 ms
20,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>

#define ios_close std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr)

using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
#define Pi  acos(-1.0);
#define PINF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

void solve(){
    std::vector<ll> pre(1000010);
    int n;
    ll k;
    scanf("%d %lld", &n, &k);
    for(int i = 1; i <= n; i ++ ){
        pre[i] = pre[i - 1] + i;
    }
    if(pre[n] == k){
        printf("0");
        return ;
    }
    std::unordered_set<ll> S;
    S.insert(0);
    ll t = k - pre[n];
    for(int i = 1; i <= n; i ++ ){
        if(S.count(t + pre[i])){
            printf("1");
            return ;
        }
        S.insert(pre[i]);
    }
    printf("2");
}

int main(){
#if 0
    ios_close;
#endif

#if 0
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
    int T = 1;
#if 0
    std::cin >> T;
#endif
    while(T -- ){
        solve();
    }
    return 0;
}
0