結果
問題 |
No.2845 Birthday Pattern in Two Different Calendars
|
ユーザー |
![]() |
提出日時 | 2024-08-23 22:45:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 843 bytes |
コンパイル時間 | 919 ms |
コンパイル使用メモリ | 97,536 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-23 22:45:11 |
合計ジャッジ時間 | 4,644 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 16 |
ソースコード
#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, s = 1; while (ans.size() < n) { while (s <= k && (used[s] || used[cal(s)])) ++s; if (s > k) break; now = s; while (ans.size() < n && !used[now] && !used[cal(now)]) { ans.push_back(now); used[now] = 1; used[cal(now)] = 1; now += m; now = (now - 1) % k + 1; } } 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(); }