結果

問題 No.839 Keep Distance and Nobody Explodes
ユーザー LayCurseLayCurse
提出日時 2019-06-14 21:58:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,674 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 194,636 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 16:26:50
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int res[300][300];
int main(){
  int i, j, k;
  rd(N);
  k = N*N/2;
  for(i=0;i<k;i++){
    if((i/N)%2==0){
      res[i/N][i%N] = 2*i+1;
    }
    else{
      res[i/N][((-i-1)%N+N)%N] = 2*i+1;
    }
  }
  for(i=0;i<k;i++){
    if((i/N)%2==0){
      res[i/N+N/2][(i+N/2)%N] = 2*i+2;
    }
    else{
      res[i/N+N/2][((-i-1+N/2)%N+N)%N] = 2*i+2;
    }
  }
  for(i=0;i<N;i++){
    {
      int Lj4PdHRW;
      if(N==0){
        putchar_unlocked('\n');
      }
      else{
        for(Lj4PdHRW=0;Lj4PdHRW<N-1;Lj4PdHRW++){
          wt_L(res[i][Lj4PdHRW]);
          wt_L(' ');
        }
        wt_L(res[i][Lj4PdHRW]);
        wt_L('\n');
      }
    }
  }
  return 0;
}
// cLay varsion 20190609-2 [beta]

// --- original code ---
// int N;
// int res[300][300];
// {
//   int i, j, k;
//   rd(N);
// 
//   k = N*N/2;
//   rep(i,k) res[i/N][if[(i/N)%2==0,i%N,((-i-1)%N+N)%N]] = 2i+1;
//   rep(i,k) res[i/N+N/2][if[(i/N)%2==0,(i+N/2)%N,((-i-1+N/2)%N+N)%N]] = 2i+2;
// 
//   rep(i,N) wt(res[i](N));
// }
0