結果
| 問題 |
No.1831 Parasol
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-02-06 11:50:49 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 1,090 bytes |
| コンパイル時間 | 1,859 ms |
| コンパイル使用メモリ | 141,468 KB |
| 実行使用メモリ | 5,632 KB |
| 最終ジャッジ日時 | 2024-06-11 13:45:56 |
| 合計ジャッジ時間 | 2,930 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
int mapping[2 * N][2 * N];
memset(mapping, -1, sizeof(mapping));
for (int x = 2 * N - 1; x >= 1; --x) {
if (x % 2 == 0) {
for (int y = 1; y <= x; ++y) {
mapping[y][x] = 2 * N - y;
}
} else {
for (int y = x; y >= 1; --y) {
mapping[y][x] = x - y + 1;
}
}
}
vector<int> counter(2 * N, 0);
int ans[2 * N][N];
for (int y = 1; y <= 2 * N - 1; ++y) {
for (int x = 1; x <= 2 * N - 1; ++x) {
int id = mapping[y][x];
if (id == -1) continue;
int idx = counter[id];
ans[id][idx] = x;
counter[id]++;
}
}
cout << 2 * N - 1 << endl;
for (int id = 1; id <= 2 * N - 1; ++id) {
for (int i = 0; i < N; ++i) {
cout << ans[id][i];
if (i != N - 1) cout << " ";
}
cout << endl;
}
return 0;
}
siman