結果

問題 No.3334 I hate Image Convolution
コンテスト
ユーザー iris2617
提出日時 2025-11-18 21:21:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 3,000 ms
コード長 848 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 204,724 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2025-11-18 21:21:45
合計ジャッジ時間 16,403 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define int long long
#define matsuri pair<int,int>
//const int iris = 1e9+7;
const int iris = 998244353;
using namespace std;

void solve()
{
	int n;
	cin>>n;
	vector<vector<int> > arr(n, vector<int>(n, 0));
	vector<int> owo((n-1)*(n-1));
	for(int &x:owo)
		cin>>x;
	sort(owo.begin(), owo.end());
	for(int i=0;i<owo.size();i++)
	{
		int a=owo[i];
		if(i)
			a-=owo[i-1];
		int x=i/(n-1), y=i%(n-1);
		x++, y++;
		arr[x][y]+=a;
		if(x<n-1)
		{
			arr[x+1][y%2]+=a;
			arr[x+1][y]-=a;
		}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			if(i>=2)
				arr[i][j]+=arr[i-2][j];
			if(j>=2)
				arr[i][j]+=arr[i][j-2];
			if(i>=2 && j>=2)
				arr[i][j]-=arr[i-2][j-2];
			cout<<arr[i][j]<<" \n"[j==n-1];
		}
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int T=1;
	cin>>T;
	while(T--)
		solve();

	return 0;
}
0