結果

問題 No.532 Possible or Impossible
ユーザー t98slidert98slider
提出日時 2023-02-12 20:47:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 170,264 KB
実行使用メモリ 4,412 KB
最終ジャッジ日時 2023-09-23 06:53:01
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> dp(n + 1, vector<bool>(200001));
    dp[1][100001] = true;
    for(int i = 1; i < n; i++){
        int v = i + 1;
        for(int j = 0; j <= 200000; j++){
            if(!dp[i][j])continue;
            dp[i + 1][j] = true;
            if(j + v <= 200000) dp[i + 1][j + v] = true;
            if(j - v >= 0) dp[i + 1][j - v] = true;
            ll v = j - 100000;
            if(-100000 <= v * j && v * j <= 100000) dp[i + 1][v * j + 100000] = true;
        }
    }
    cout << (dp[n][m + 100000] ? "Possible" : "Impossible") << '\n';
}
0