結果
| 問題 |
No.3057 Tree Distance Set
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-03-18 13:24:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 737 bytes |
| コンパイル時間 | 453 ms |
| コンパイル使用メモリ | 41,216 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-18 13:24:43 |
| 合計ジャッジ時間 | 2,296 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d", &k);
| ~~~~~^~~~~~~~~~
main.cpp:30:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | for (int i = 0; i < k; i++) scanf("%d", ds + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3057.cc: No.3057 Tree Distance Set - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_K = 150;
const int MAX_D = 300;
const int MAX_N = MAX_D + 1;
/* typedef */
/* global variables */
int ds[MAX_N];
/* subroutines */
/* main */
int main() {
int k;
scanf("%d", &k);
for (int i = 0; i < k; i++) scanf("%d", ds + i);
int maxd = *max_element(ds, ds + k);
int n = maxd + 1;
printf("%d\n", n);
for (int i = 2; i <= maxd; i += 2) {
printf("%d %d %d\n", i, i + 1, i / 2);
printf("%d %d %d\n", i + 1, i - 1, 1);
}
printf("%d\n1", k + 1);
for (int i = 0; i < k; i++) printf(" %d", ds[i]);
putchar('\n');
return 0;
}
tnakao0123