結果

問題 No.532 Possible or Impossible
ユーザー t98slidert98slider
提出日時 2023-02-12 20:49:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 168,892 KB
実行使用メモリ 4,492 KB
最終ジャッジ日時 2023-09-23 06:53:04
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 14 ms
4,376 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 39 ms
4,404 KB
testcase_17 AC 43 ms
4,444 KB
testcase_18 AC 43 ms
4,492 KB
testcase_19 AC 43 ms
4,384 KB
testcase_20 AC 42 ms
4,380 KB
testcase_21 AC 25 ms
4,376 KB
testcase_22 AC 3 ms
4,384 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 v2 = j - 100000;
            if(-100000 <= v2 * v && v2 * v <= 100000) dp[i + 1][v2 * v + 100000] = true;
        }
    }
    cout << (dp[n][m + 100000] ? "Possible" : "Impossible") << '\n';
}
0