結果
問題 | No.2845 Birthday Pattern in Two Different Calendars |
ユーザー |
|
提出日時 | 2024-08-23 22:06:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,389 bytes |
コンパイル時間 | 1,981 ms |
コンパイル使用メモリ | 199,204 KB |
最終ジャッジ日時 | 2025-02-23 23:48:42 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} void solve(){ int K,M,N; cin>>K>>M>>N; M--; if(M==0||2*N>K){ cout<<"No\n"; }else{ vector<int>to(K); for(int y=0;y<K;y++){ int c=(y+M)%K; to[y]=c; } vector<int>V; vector<bool>used(K); for(int i=0;i<K;i++){ if(used[i])continue; int at=to[i]; used[i]=true; bool ok=true; V.push_back(i); while(at!=i){ used[at]=true; ok=!ok; if(ok){ V.push_back(at); } at=to[at]; } if(ok){ V.pop_back(); } } if((int)V.size()<N){ cout<<"No\n"; }else{ cout<<"Yes\n"; for(int i=0;i<N;i++){ cout<<V[i]+1<<" "; } cout<<"\n"; } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ solve(); } }