結果
問題 |
No.2845 Birthday Pattern in Two Different Calendars
|
ユーザー |
![]() |
提出日時 | 2024-08-23 21:57:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 956 ms |
コンパイル使用メモリ | 97,108 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-23 21:57:06 |
合計ジャッジ時間 | 4,638 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 15 |
ソースコード
#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(); }