結果
| 問題 | No.3722 Blended Taste |
| コンテスト | |
| ユーザー |
テナガザル
|
| 提出日時 | 2026-09-19 13:41:12 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,302 bytes |
| 記録 | |
| コンパイル時間 | 1,047 ms |
| コンパイル使用メモリ | 174,860 KB |
| 実行使用メモリ | 12,728 KB |
| 最終ジャッジ日時 | 2026-09-19 13:41:21 |
| 合計ジャッジ時間 | 4,718 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 WA * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<vector<int>> a(n, vector<int> (n));
vector<int> cnt(m + 1, n * n / m);
cnt[0] = 0;
int num = 0;
for (int i = k - 1; i >= 0; --i)
{
for (int j = 0; j <= i; ++j)
{
++num;
if (num > m) break;
for (int bx = i; bx < n; bx += k)
{
for (int by = j; by < n; by += k)
{
a[bx][by] = num;
--cnt[num];
}
}
++num;
if (num > m) break;
if (j < i)
{
for (int bx = j; bx < n; bx += k)
{
for (int by = i; by < n; by += k)
{
a[bx][by] = num;
--cnt[num];
}
}
}
}
}
vector<int> nok;
for (int i = 1; i <= m; ++i)
{
if (cnt[i] < 0)
{
cout << -1 << endl;
return 0;
}
while (cnt[i] > 0)
{
--cnt[i];
nok.push_back(i);
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (a[i][j] == 0)
{
a[i][j] = nok.back();
nok.pop_back();
}
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
cout << a[i][j] << " \n"[j == n - 1];
}
}
}
テナガザル