結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー テナガザルテナガザル
提出日時 2024-08-23 21:57:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 97,108 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-23 21:57:06
合計ジャッジ時間 4,638 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 14 ms
6,944 KB
testcase_22 AC 607 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
  int k, m, n;
  cin >> k >> m >> n;
  if (n * 2 > k || m == 1)
  {
    cout << "No" << endl;
    return;
  }
  auto cal = [&](int d) -> int {return (d + m - 2) % k + 1;};
  vector<int> ans, used(k + 1);
  int now = 1;
  while (ans.size() < n)
  {
    while (now <= k && used[now]) ++now;
    if (now > k) break;
    int d = cal(now);
    if (!used[d])
    {
      used[now] = 1;
      used[d] = 1;
      ans.push_back(now);
    }
    else ++now;
  }
  if (ans.size() == n)
  {
    cout << "Yes" << endl;
    for (auto v : ans) cout << v << ' ';
    cout << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

int main()
{
  int t;
  cin >> t;
  while (t--) solve();
}
0