結果
| 問題 | No.3618 Omega Cat(Making ver.) |
| コンテスト | |
| ユーザー |
mocchi
|
| 提出日時 | 2026-08-06 15:50:56 |
| 言語 | C++23(gnu拡張gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,164 bytes |
| 記録 | |
| コンパイル時間 | 2,630 ms |
| コンパイル使用メモリ | 357,896 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-06 15:51:07 |
| 合計ジャッジ時間 | 9,552 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | RE * 1 |
| 小課題1 | 20 % | WA * 5 |
| 小課題2 | 20 % | WA * 12 |
| 小課題3 | 40 % | WA * 12 RE * 12 |
| 小課題4 | 20 % | WA * 12 RE * 26 |
| 合計 | 3.5 * 0% = 0 点 |
ソースコード
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
constexpr int inf = 1e9;
signed main() {
int T;
cin >> T;
while (T--)
{
int N;
cin >> N;
vector H(N,0LL);
rep(i,N) cin >> H[i];
assert(N <= 8);
int ans = inf;
auto cop = H;
do
{
int phase = 0;
if (H[0] < H[1])
{
continue;
}
for (int i = 0; i < N - 1; i++)
{
if (phase % 2 == 0)
{
if (H[i] < H[i + 1]) phase++;
}
if (phase % 2 == 1)
{
if (H[i] > H[i + 1]) phase++;
}
}
if (phase == 3)
{
int cnt = 0;
for (int i = 0; i < N; i++)
{
cnt += (cop[i] != H[i]);
}
ans = min(ans,cnt);
}
}while (ranges::next_permutation(H).found);
cout << ans << endl;
}
}
mocchi