結果
| 問題 | No.1087 転倒数の転倒数 |
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2020-06-19 22:53:00 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 940 bytes |
| 記録 | |
| コンパイル時間 | 1,395 ms |
| コンパイル使用メモリ | 214,752 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2026-06-10 20:52:34 |
| 合計ジャッジ時間 | 8,817 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
int main()
{
int N, K;
cin >> N >> K;
vector mat(N, vector<int>(N));
int i = 0, j = 0;
while (i < N and j < N)
{
int a = N - 1 - i + N - 1 - j;
if (i == N - 2 and j == N - 2 and K == 1)
{
mat[i][j] = mat[i + 1][j] = mat[i + 1][j + 1] = 1;
i += 2, j += 2, K -= 1;
}
else if (a <= K)
{
K -= a;
mat[i][j] = 1;
i++, j++;
}
else
{
if (i < j) i++;
else j++;
}
}
if (K)
{
puts("No");
}
else
{
cout << "Yes" << '\n';
for (auto vec : mat)
{
for (auto x : vec) cout << x << ' ';
cout << '\n';
}
}
}
hitonanode