提出 #41204876
ソースコード 拡げる
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b){ if (a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if (a < b){a = b; return true;} return false;}
//using mint = modint998244353;
//using mint = modint1000000007;
//using mint = modint; // mint::set_mod(p); later
//using mint = static_modint<1000000009>;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<string> s(N);
for (auto &t : s) cin >> t;
int MOD = M+1;
vector<vector<ll>> dp(MOD, vector<ll>(N+1, INF));
dp[1][0] = 0;
for (int i = 1; i < N; i++){
for (int j = 0; j <= N; j++){
if (dp[i%MOD][j] == INF) continue;
for (int k = 0; k < M; k++){
if (s[i-1][k] == '1'){
int ni = i + k + 1;
if (ni <= N){
chmin(dp[ni%MOD][j], dp[i%MOD][j] + 1);
for (int nj = i + 1; nj <= i + k; nj++){
chmin(dp[ni%MOD][nj], dp[i%MOD][j] + 1);
}
}
}
}
}
for (auto &t : dp[i%MOD]) t = INF;
}
for (int i = 2; i < N; i++){
ll dist = dp[N%MOD][i];
if (dist == INF) { cout << -1 << " "; }
else { cout << dist << " "; }
}
cout << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | F - Teleporter and Closed off |
| ユーザ | unnohideyuki |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 0 |
| コード長 | 1442 Byte |
| 結果 | TLE |
| 実行時間 | 2206 ms |
| メモリ | 15872 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 500 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | colored_00.txt, colored_01.txt, colored_02.txt, colored_03.txt, colored_04.txt, colored_05.txt, colored_06.txt, colored_07.txt, colored_08.txt, colored_09.txt, colored_10.txt, colored_11.txt, colored_12.txt, colored_13.txt, colored_14.txt, colored_15.txt, colored_16.txt, colored_17.txt, colored_18.txt, colored_19.txt, colored_20.txt, colored_21.txt, colored_22.txt, colored_23.txt, colored_24.txt, colored_25.txt, example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| colored_00.txt | TLE | 2206 ms | 13816 KiB |
| colored_01.txt | TLE | 2206 ms | 14676 KiB |
| colored_02.txt | TLE | 2206 ms | 14780 KiB |
| colored_03.txt | TLE | 2206 ms | 13820 KiB |
| colored_04.txt | TLE | 2206 ms | 14764 KiB |
| colored_05.txt | TLE | 2206 ms | 15016 KiB |
| colored_06.txt | TLE | 2206 ms | 14768 KiB |
| colored_07.txt | TLE | 2206 ms | 15016 KiB |
| colored_08.txt | TLE | 2206 ms | 14236 KiB |
| colored_09.txt | TLE | 2206 ms | 15548 KiB |
| colored_10.txt | TLE | 2206 ms | 13884 KiB |
| colored_11.txt | TLE | 2206 ms | 14612 KiB |
| colored_12.txt | TLE | 2206 ms | 14016 KiB |
| colored_13.txt | TLE | 2206 ms | 14676 KiB |
| colored_14.txt | TLE | 2206 ms | 15468 KiB |
| colored_15.txt | TLE | 2206 ms | 14240 KiB |
| colored_16.txt | TLE | 2206 ms | 14676 KiB |
| colored_17.txt | TLE | 2206 ms | 13956 KiB |
| colored_18.txt | TLE | 2206 ms | 14768 KiB |
| colored_19.txt | TLE | 2206 ms | 13924 KiB |
| colored_20.txt | TLE | 2206 ms | 15532 KiB |
| colored_21.txt | TLE | 2206 ms | 13816 KiB |
| colored_22.txt | TLE | 2206 ms | 13820 KiB |
| colored_23.txt | TLE | 2206 ms | 14224 KiB |
| colored_24.txt | TLE | 2206 ms | 14768 KiB |
| colored_25.txt | TLE | 2206 ms | 15560 KiB |
| example_00.txt | AC | 6 ms | 3644 KiB |
| example_01.txt | AC | 2 ms | 3464 KiB |
| hand_00.txt | TLE | 2206 ms | 15772 KiB |
| hand_01.txt | TLE | 2206 ms | 15868 KiB |
| hand_02.txt | TLE | 2206 ms | 15772 KiB |
| hand_03.txt | TLE | 2206 ms | 15808 KiB |
| hand_04.txt | TLE | 2206 ms | 15792 KiB |
| hand_05.txt | TLE | 2206 ms | 8604 KiB |
| hand_06.txt | TLE | 2206 ms | 15868 KiB |
| hand_07.txt | TLE | 2206 ms | 15872 KiB |
| random_00.txt | TLE | 2206 ms | 13964 KiB |
| random_01.txt | TLE | 2206 ms | 14776 KiB |
| random_02.txt | AC | 5 ms | 3632 KiB |
| random_03.txt | TLE | 2206 ms | 15544 KiB |
| random_04.txt | TLE | 2206 ms | 14780 KiB |
| random_05.txt | AC | 8 ms | 3632 KiB |
| random_06.txt | TLE | 2206 ms | 15508 KiB |
| random_07.txt | TLE | 2206 ms | 15468 KiB |
| random_08.txt | AC | 6 ms | 3620 KiB |
| random_09.txt | TLE | 2206 ms | 14764 KiB |
| random_10.txt | TLE | 2206 ms | 15384 KiB |
| random_11.txt | AC | 29 ms | 3428 KiB |
| random_12.txt | TLE | 2206 ms | 15320 KiB |
| random_13.txt | TLE | 2206 ms | 13832 KiB |