結果

問題 No.459 C-VS for yukicoder
ユーザー vjudge1
提出日時 2025-06-26 17:37:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 198,320 KB
実行使用メモリ 21,604 KB
最終ジャッジ日時 2025-06-26 17:37:47
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N=5e5+7;
int n,m,k,cnt[N],a[N],res[N][3];
vector<int>T[N];
signed main(){
//	freopen("tetris.in","r",stdin);
//	freopen("tetris.out","w",stdout);
	cin>>n>>m>>k;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			char ch;cin>>ch;
			if(ch=='#')cnt[j]++;
		}
	for(int i=1;i<=k;i++)cin>>a[i],a[i]++,T[a[i]].push_back(i);
	for(int i=1;i<=m;i++)
		for (int x:T[i]){
			if(cnt[i])res[x][0]++,cnt[i]--;
			else if(i+1<=m&&cnt[i+1])res[x][1]++,cnt[i+1]--;
			else if(i+2<=m&&cnt[i+2])res[x][2]++,cnt[i+2]--;
		}
	for(int i=1;i<=m;i++)
		for (int x:T[i])
		    for(int k=0;k<3;k++)
		    	if(i+k<=m){
		    		int p=res[x][k];
		    		res[x][k]+=cnt[i+k];
		    		cnt[i+k]-=min(3-p,cnt[i+k]);
				}
	for (int i=1;i<=k;i++)
		for (int j=1;j<=3;j++){
			for (int k=0;k<3;k++)
				if(j<=res[i][k]) cout<<'#';
				else cout<<'.';
			cout<<"\n";
		}
}
0