結果

問題 No.1619 Coccinellidae
ユーザー 👑 NachiaNachia
提出日時 2021-07-22 21:53:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 80,412 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-24 16:38:16
合計ジャッジ時間 2,087 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  ll N,M,K; cin >> N >> M >> K;
  deque<ll> A(N);
  rep(i,N) A[i] = i;
  A[N-1] += M - (N*(N-1)/2);
  deque<ll> ans;
  while(K != 0){
    if(ans.size() <= K){
      K -= ans.size();
      ans.push_front(A.front());
      A.pop_front();
    }
    else{
      ans.push_back(A.front());
      A.pop_front();
      int p = ans.size()-1;
      while(K != 0){
        K--;
        swap(ans[p-1],ans[p]);
        p--;
      }
    }
  }
  while(A.size()){
    ans.push_back(A.front());
    A.pop_front();
  }
  rep(i,N){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}

0