結果
| 問題 | No.3506 All Distance is Square Number |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-04-20 15:00:18 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,318 bytes |
| 記録 | |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 72,228 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-20 15:00:23 |
| 合計ジャッジ時間 | 2,279 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3506.cc: No.3506 All Distance is Square Number - yukicoder
*/
#include<cstdio>
#include<cassert>
#include<vector>
#include<algorithm>
#include<tuple>
using namespace std;
/* constant */
const int MAX_N = 100;
const int MAX_M = MAX_N * 2 - 3;
/* typedef */
using vi = vector<int>;
using tp3 = tuple<int,int,int>;
/* global variables */
tp3 es[MAX_M];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
int m = 0;
for (int i = 0; i + 1 < n; i++)
es[m++] = {i, i + 1, 2 * i + 1};
for (int i = 2; i < n; i++)
es[m++] = {1, i, 2 * i};
printf("%d\n", m);
for (int i = 0; i < m; i++) {
auto [u, v, w] = es[i];
printf("%d %d %d\n", u + 1, v + 1, w);
}
for (int x = 0; x < n; x++)
for (int y = x + 1; y < n; y++) {
vi q;
int u = x;
int sum = 0;
if (u != 0) {
while (u > 1) {
q.push_back(u - 1);
sum += get<2>(es[u - 1]);
u--;
}
u = x + 1;
q.push_back((n - 1) + u - 2);
sum += get<2>(es[(n - 1) + u - 2]);
}
while (u < y) {
q.push_back(u);
sum += get<2>(es[u]);
u++;
}
//printf(" sum=%d, y=%d\n", sum, y);
//assert(sum == y * y);
printf("%d", (int)q.size());
for (auto u: q) printf(" %d", u + 1);
putchar('\n');
}
return 0;
}
tnakao0123