結果

問題 No.2845 Birthday Pattern in Two Different Calendars
コンテスト
ユーザー MM
提出日時 2024-08-23 21:26:29
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,364 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,266 ms
コンパイル使用メモリ 374,984 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-03 21:54:57
合計ジャッジ時間 6,963 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<int>>;
const vector<int> dx ={1,0,-1,0}, dy = {0,1,0,-1};

// https://betrue12.hateblo.jp/entry/2020/09/22/194541
struct S{
  int value;
  int size;
};
using F = int;
const F ID = int(2e9);
S op(S a, S b){ return {a.value+b.value, a.size+b.size}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
  if(f != ID) x.value = x.size * f;
  return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }


int main() {
  int t; cin >> t;
  while(t--){
    // input
    int K,M,N;
    cin >> K >> M >> N;
    assert(M <= K && N <= K);
    
    // solve: simulation
    vector<int> used(K);
    vector<int> ans;
    int now = 0;
    while(now < K && ans.size() < N){
      int coder = (now+M-1) % K;
      if(!used[now] && !used[coder] && now != coder){
        used[now] = 1;
        used[coder] = 1;
        ans.push_back(now);
      }
      now++;
    }
    
    // output
    cout << (ans.size() == N ? "Yes" : "No") << endl;
    if(ans.size() == N){
      for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << ans[i]+1;
      } cout << endl;
    }
  }
  
}
0