結果
| 問題 |
No.918 LISGRID
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-26 00:55:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,167 bytes |
| コンパイル時間 | 983 ms |
| コンパイル使用メモリ | 76,972 KB |
| 実行使用メモリ | 15,172 KB |
| 最終ジャッジ日時 | 2024-09-13 11:59:36 |
| 合計ジャッジ時間 | 4,213 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
コンパイルメッセージ
main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main()
| ^~~~
ソースコード
#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":" ");
}
}