結果

問題 No.839 Keep Distance and Nobody Explodes
ユーザー TangentDayTangentDay
提出日時 2019-06-14 22:21:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,903 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 89,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 17:09:27
合計ジャッジ時間 2,375 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
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 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int in()’:
main.cpp:36:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 | int in() { int x; scanf("%d", &x); return x; }
      |                   ~~~~~^~~~~~~~~~
main.cpp: In function ‘ll lin()’:
main.cpp:37:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 | ll lin() { ll x; scanf("%lld", &x); return x; }
      |                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;

    VVI a(n, VI(n));
    int c = 1, m = (n + 1) / 2;

    if (n % 2){
        REP(i,m){
            REP(j,i+1){
                a[m - 1 + j][m - 1 + i - j] = c++;
                a[j][i - j] = c++;
            }
        }
        REP(i,m-1){
            REP(j,m-1-i){
                a[m + i + j][n - 1 - j] = c++;
                if (c < 2 * m * m) a[i + j + 1][m - 1 - j] = c++;
            }
        }
        REP(i,m-1){
            REP(j,m-1){
                a[i][m+j] = c++;
                a[m+i][j] = c++;
            }
        }
    }else{
        REP(i,m){
            REP(j,m){
                a[i][j] = c++;
                a[m+i][m+j] = c++;
            }
        }
        REP(i,m){
            REP(j,m){
                a[i][m+j] = c++;
                a[m+i][j] = c++;
            }
        }
    }

    REP(i,n){
        REP(j,n) cout << a[i][j] << " ";
        // REP(j,n) printf("%03d ", a[i][j]);
        cout << endl;
    }

    return 0;
}
0