結果

問題 No.918 LISGRID
ユーザー kotatsugamekotatsugame
提出日時 2019-10-26 00:55:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 77,212 KB
実行使用メモリ 14,712 KB
最終ジャッジ日時 2023-10-11 13:13:50
合計ジャッジ時間 4,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,304 KB
testcase_01 AC 31 ms
12,100 KB
testcase_02 AC 13 ms
9,180 KB
testcase_03 AC 16 ms
9,632 KB
testcase_04 AC 13 ms
9,048 KB
testcase_05 AC 37 ms
12,644 KB
testcase_06 AC 34 ms
12,492 KB
testcase_07 AC 50 ms
14,332 KB
testcase_08 AC 31 ms
11,460 KB
testcase_09 AC 40 ms
12,764 KB
testcase_10 AC 39 ms
12,856 KB
testcase_11 AC 39 ms
12,904 KB
testcase_12 AC 42 ms
13,112 KB
testcase_13 AC 35 ms
12,328 KB
testcase_14 AC 50 ms
14,064 KB
testcase_15 AC 56 ms
14,712 KB
testcase_16 AC 21 ms
10,216 KB
testcase_17 AC 23 ms
10,480 KB
testcase_18 AC 22 ms
10,432 KB
testcase_19 AC 9 ms
8,336 KB
testcase_20 AC 28 ms
11,364 KB
testcase_21 AC 10 ms
8,424 KB
testcase_22 AC 7 ms
7,972 KB
testcase_23 AC 19 ms
10,296 KB
testcase_24 AC 5 ms
7,600 KB
testcase_25 AC 4 ms
7,176 KB
testcase_26 AC 3 ms
7,112 KB
testcase_27 AC 4 ms
7,132 KB
testcase_28 AC 3 ms
7,120 KB
testcase_29 AC 3 ms
7,148 KB
testcase_30 AC 3 ms
7,160 KB
testcase_31 AC 4 ms
7,372 KB
testcase_32 AC 3 ms
7,192 KB
testcase_33 AC 3 ms
7,352 KB
testcase_34 AC 5 ms
7,548 KB
testcase_35 AC 5 ms
7,924 KB
testcase_36 AC 4 ms
7,420 KB
testcase_37 AC 28 ms
11,232 KB
testcase_38 AC 20 ms
9,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   22 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int H,W;
vector<pair<int,int> >G[400][400];
int A[400],B[400];
int cnt[400][400];
vector<pair<int,int> >S;
bool vis[400][400];
int ans[400][400];
void dfs(int i,int j)
{
	vis[i][j]=true;
	for(pair<int,int>p:G[i][j])
	{
		if(vis[p.first][p.second])continue;
		dfs(p.first,p.second);
	}
	S.push_back(make_pair(i,j));
}
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>A[i];
	sort(A,A+H);
	for(int i=0;i<H;i++)
	{
		for(int j=0;j+1<W;j++)
		{
			if(j<W-A[i])G[i][j].push_back(make_pair(i,j+1));
			else G[i][j+1].push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<W;i++)cin>>B[i];
	sort(B,B+W);
	for(int j=0;j<W;j++)
	{
		for(int i=0;i+1<H;i++)
		{
			if(i<H-B[j])G[i][j].push_back(make_pair(i+1,j));
			else G[i+1][j].push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		for(pair<int,int>p:G[i][j])cnt[p.first][p.second]++;
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(vis[i][j]||cnt[i][j])continue;
		dfs(i,j);
	}
	for(int i=0;i<H*W;i++)ans[S[i].first][S[i].second]=i+1;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)cout<<ans[i][j]<<(j+1==W?"\n":" ");
	}
}
0