結果

問題 No.3341 Making Beautiful Graphs
コンテスト
ユーザー tnakao0123
提出日時 2025-11-14 18:52:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 41,532 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-14 18:52:40
合計ジャッジ時間 4,059 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3341.cc:  No.3341 Making Beautiful Graphs - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_NN = MAX_N * MAX_N;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  if (n <= 2) { puts("-1"); return 0; }

  int nn = n * n;

  printf("%d\n", nn * 2);
  for (int i = 0, u = 0; i < n; i++)
    for (int j = 0; j < n; j++, u++) {
      int v0 = (u + n) % nn, v1 = (u + 1) % nn;
      printf("%d %d\n", u + 1, v0 + 1);
      printf("%d %d\n", u + 1, v1 + 1);
    }

  return 0;
}

0