結果

問題 No.606 カラフルタイル
ユーザー Sebastian KingSebastian King
提出日時 2017-12-06 00:12:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 143,864 KB
実行使用メモリ 11,064 KB
最終ジャッジ日時 2023-08-19 05:01:57
合計ジャッジ時間 3,192 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,904 KB
testcase_01 AC 3 ms
9,596 KB
testcase_02 AC 3 ms
10,496 KB
testcase_03 AC 3 ms
9,592 KB
testcase_04 AC 2 ms
9,708 KB
testcase_05 AC 3 ms
9,696 KB
testcase_06 AC 3 ms
9,760 KB
testcase_07 AC 3 ms
9,792 KB
testcase_08 AC 3 ms
9,668 KB
testcase_09 AC 3 ms
9,600 KB
testcase_10 AC 2 ms
9,664 KB
testcase_11 AC 3 ms
9,792 KB
testcase_12 AC 2 ms
9,680 KB
testcase_13 AC 4 ms
9,696 KB
testcase_14 AC 4 ms
10,584 KB
testcase_15 AC 3 ms
9,796 KB
testcase_16 AC 20 ms
9,592 KB
testcase_17 AC 34 ms
10,536 KB
testcase_18 AC 22 ms
10,060 KB
testcase_19 AC 21 ms
10,000 KB
testcase_20 AC 39 ms
11,000 KB
testcase_21 AC 26 ms
10,392 KB
testcase_22 AC 27 ms
10,524 KB
testcase_23 AC 29 ms
10,588 KB
testcase_24 AC 33 ms
10,904 KB
testcase_25 AC 33 ms
11,064 KB
testcase_26 AC 34 ms
10,952 KB
testcase_27 AC 34 ms
10,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e5 + 10;

int n, m;

void prework(){

}

void read(){

}

int r[MAXN], c[MAXN], rt[MAXN], ct[MAXN];
int z[MAXN], X[MAXN], Y[MAXN];
ll ans[MAXN];
int visr[MAXN], visc[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	int Q;
	scanf("%d%d%d", &n, &m, &Q);
	for (int i = 1; i <= n; i++){
		r[i] = 1, rt[i] = 0;
		c[i] = 1, ct[i] = 0;
	}
	for (int i = 1; i <= Q; i++){
		char s[10];
		int x, y;
		scanf("%s%d%d", s, &x, &y);
		if (s[0] == 'R'){
			r[x] = y;
			rt[x] = i;
		}
		else{
			c[x] = y;
			ct[x] = i;
		}
		z[i] = s[0]=='R';
		X[i] = x;
		Y[i] = y;
	}
	for (int i = 1; i <= m; i++)
		ans[i] = 0;
	for (int i = 1; i <= n; i++)
		visr[i] = visc[i] = 0;
	int R = n, C = n;
	for (int i = Q; i >= 1; i--){
		if (z[i] == 1){
			if (visr[X[i]])
				;
			else{
				ans[Y[i]] += C;
				R--;
				visr[X[i]] = 1;
			}
		}
		else{
			if (visc[X[i]])
				;
			else{
				ans[Y[i]] += R;
				C--;
				visc[X[i]] = 1;
			}
		}
	}
	ans[1] = 1ll * n * n;
	for (int i = 2; i <= m; i++)
		ans[1] -= ans[i];
	for (int i = 1; i <= m; i++)
		printf("%lld\n", ans[i]);
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

0