結果

問題 No.1087 転倒数の転倒数
ユーザー 👑 NachiaNachia
提出日時 2021-01-22 20:31:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 199,496 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 16:20:22
合計ジャッジ時間 25,050 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 91 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 3 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 7 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 49 ms
4,376 KB
testcase_30 AC 25 ms
4,380 KB
testcase_31 AC 67 ms
4,376 KB
testcase_32 AC 67 ms
4,380 KB
testcase_33 AC 41 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 90 ms
4,380 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N,K;
int P[1000];

void calcP(int n,int k){
  rep(i,n) P[i]=i;
  int x=n-1;
  while(k>x){ P[n-1-x]=x; k-=x; x--; }
  rep(i,x+1) P[N-x-1+i]=i;
  for(int i=n-1; i>0; i--) if(k){ swap(P[i-1],P[i]); k--; }
}

int main() {
  scanf("%d%d",&N,&K);
  if(N*(N-1)<K){ printf("No\n"); return 0; }
  printf("Yes\n");
  bool big = N*(N-1)/2<=K;
  if(big) K-=N*(N-1)/2;
  calcP(N,K);
  rep(i,N){
    rep(j,N){
      int iv,jv;
      iv=(big?N-1-i:i);
      if(P[i]>j) jv=j+1; else if(P[i]==j) jv=0; else jv=j;
      if(j) printf(" "); printf("%d",iv*N+jv);
    }
    printf("\n");
  }
  return 0;
}
0