結果
問題 | No.873 バイナリ、ヤバいなり!w |
ユーザー |
|
提出日時 | 2019-08-30 22:29:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,001 bytes |
コンパイル時間 | 2,557 ms |
コンパイル使用メモリ | 199,716 KB |
最終ジャッジ日時 | 2025-01-07 15:58:43 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 36 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:15:29: warning: overflow in conversion from ‘long long int’ to ‘int’ changes value from ‘576460752303423488’ to ‘0’ [-Woverflow] 15 | REP(i, N+1) dp[i] = 1LL << 59; | ~~~~^~~~~
ソースコード
#include <bits/stdc++.h> #include <vector> using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) #define REP2(i,m,n) for (int i=m;i<(n);i++) typedef long long ll; int N; int dp[303030]; vector<bool> ans[303030]; vector<bool> tmp; void solve() { cin >> N; REP(i, N+1) dp[i] = 1LL << 59; dp[0] = 0; REP(i, N) for (ll j = 1; i + j * j <= N; ++j) { if (dp[i] + j < dp[i + j * j]) { dp[i + j * j] = dp[i] + j; ans[i + j * j] = ans[i]; int last = i == 0 ? 0 : ans[i].back(); REP(_, j) ans[i + j * j].push_back(last), last ^= 1; } else if (dp[i] + j == dp[i + j * j]) { tmp = ans[i]; int last = i == 0 ? 0 : ans[i].back(); REP(_, j) tmp.push_back(last), last ^= 1; ans[i + j * j] = min(ans[i + j * j], tmp); } } REP(i, ans[N].size()) cout << ans[N][i]; cout << "\n"; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }