結果
問題 |
No.3052 Increasing Sliding Window Minimum
|
ユーザー |
|
提出日時 | 2024-02-10 00:01:51 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,193 bytes |
コンパイル時間 | 2,855 ms |
コンパイル使用メモリ | 115,784 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-25 15:02:28 |
合計ジャッジ時間 | 7,033 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | AC * 18 RE * 24 |
ソースコード
#include <iostream> #include <vector> #include <atcoder/modint> using Int = atcoder::modint998244353; constexpr int K = 2; #include <algorithm> #include <numeric> Int naive(int n, std::vector<int> p) { Int ans = 0; p.erase(p.begin()); for (int& e : p) --e; std::vector<int> x(n); std::iota(x.begin(), x.end(), 0); do { bool ok = true; for (int i = 0, prev_min = 0; i < n; ++i) { ok &= p[i] < 0 or x[i] == p[i]; if (i + K <= n) { int curr_min = *std::min_element(x.begin() + i, x.begin() + (i + K)); ok &= prev_min <= curr_min; prev_min = curr_min; } if (not ok) break; } ans += Int{ ok }; } while (std::next_permutation(x.begin(), x.end())); return ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { int n; std::cin >> n; std::vector<int> a(n + 1, -1); for (int i = 1; i <= n; ++i) { std::cin >> a[i]; } assert(n <= 6); std::cout << naive(n, a).val() << std::endl; } }