結果

問題 No.1910 High Element on Grid
ユーザー 沙耶花沙耶花
提出日時 2022-04-22 22:26:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 920 bytes
コンパイル時間 4,945 ms
コンパイル使用メモリ 265,320 KB
実行使用メモリ 27,984 KB
最終ジャッジ日時 2023-09-06 09:00:27
合計ジャッジ時間 19,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 RE -
testcase_03 AC 1 ms
4,380 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 2 ms
4,380 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 30 ms
12,584 KB
testcase_38 AC 13 ms
6,744 KB
testcase_39 AC 13 ms
6,712 KB
testcase_40 AC 3 ms
4,380 KB
testcase_41 AC 17 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001



int main(){
	
	int h,w;
	cin>>h>>w;
	
	vector<int> r(h),c(w);
	rep(i,h)cin>>r[i];
	rep(i,w)cin>>c[i];
//	assert(r[0]==1);
//	assert(c[0]==1);
	scc_graph S(h*w);
	
	rep(i,h){
		int x = i;
		int y = 0;
		rep(j,w-1){
			if(y+1<=r[i]-1)S.add_edge(x*w+y,x*w+y+1);
			else S.add_edge(x*w+y+1,x*w);
			y++;
		}
	}
	
	rep(i,w){
		int x = 0,y = i;
		rep(j,h-1){
			if(x+1<=c[i]-1)S.add_edge(x*w+y,(x+1)*w+y);
			else S.add_edge((x+1)*w+y,y);
			x++;
		}
	}
	
	auto s = S.scc();
	assert(s.size()==h*w);
	
	vector ans(h,vector<int>(w,0));
	rep(i,s.size()){
		int t = s[i][0];
		ans[t/w][t%w] = i+5;
	}
	
	rep(i,h){
		rep(j,w){
			if(j!=0)printf(" ");
			printf("%d",ans[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}
0