結果
問題 | No.1087 転倒数の転倒数 |
ユーザー |
![]() |
提出日時 | 2020-06-19 22:53:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 2,600 ms |
コンパイル使用メモリ | 197,480 KB |
最終ジャッジ日時 | 2025-01-11 07:36:13 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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'; } } }