DISCO presents ディスカバリーチャンネル コードコンテスト2017 予選

Submission #1660240

Source codeソースコード

#include <bits/stdc++.h>
/*
*/

using namespace std;


long long int H, W;
pair<long long int, vector<string>> E(vector<string>X){
	long long int ret = 0;
	for( size_t i = 0; i < H / 2; i++ ){
		for( size_t j = 0; j < W; j++ ){
			if( X[i][j] != X[H - i - 1][j] ){
				ret++;
				X[i][j] = X[H - i - 1][j] = '.';
			}

		}
	}
	return make_pair(ret, X);
}

pair<long long int, vector<string>> F(vector<string>X){
	long long int ret = 0;
	for( size_t i = 0; i < H; i++ ){
		for( size_t j = 0; j < W / 2; j++ ){
			if( X[i][j] != X[i][W - j - 1] ){
				ret++;
				X[i][j] = X[i][W - j - 1] = '.';
			}

		}
	}
	return make_pair(ret, X);
}

long long int G(vector<string>X){
	long long int ret = 0;
	for( size_t i = 0; i < H; i++ ){
		for( size_t j = 0; j < W; j++ ){
			if( X[i][j] == 'S' ){
				ret++;
			}
		}
	}
	return ret;
}

int main(){
	cin >> H >> W;
	long long int A, B;
	cin >> A >> B;
	vector<string>D(H);
	for( size_t i = 0; i < H; i++ ){
		cin >> D[i];
	}

	long long int ans = 0;
	{
		auto ret1 = E(D);
		auto ret2 = F(ret1.second);
		auto ret3 = G(ret2.second);
		if( ret1.first == 0 ){
			ans = max(ans, ret2.first / 2 * A + ret3 / 2 * max(A, B) + ret3 / 4 * min(A, B) - A);
		} else{
			if( ret2.first == 0 ){
				ans = max(ans, ret2.first / 2 * A + ret3 / 2 * max(A, B) + ret3 / 4 * min(A, B) - B);
			} else{
				ans = max(ans, ret2.first / 2 * A + ret3 / 2 * max(A, B) + ret3 / 4 * min(A, B));
			}
		}
	}
	{
		auto ret1 = F(D);
		auto ret2 = E(ret1.second);
		auto ret3 = G(ret2.second);
		if( ret1.first == 0 ){
			ans = max(ans, ret2.first / 2 * B + ret3 / 2 * max(A, B) + ( ret3 / 4 * min(A, B) - B ));
		} else{
			if( ret2.first == 0 ){
				ans = max(ans, ret2.first / 2 * B + ret3 / 2 * max(A, B) + ( ret3 / 4 * min(A, B) -A));
			} else{
				ans = max(ans, ret2.first / 2 * B + ret3 / 2 * max(A, B) + ( ret3 / 4 * min(A, B) ));
			}
		}

	}
	cout << ans + A + B << endl;
}

Submission

Task問題 D - 石
User nameユーザ名 031_goryudyuma
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1987 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 600 01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,31.txt,32.txt,33.txt,34.txt,sample_01.txt,sample_02.txt,sample_03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 4 ms 496 KB
02.txt AC 4 ms 496 KB
03.txt AC 4 ms 496 KB
04.txt AC 4 ms 496 KB
05.txt AC 4 ms 496 KB
06.txt AC 4 ms 496 KB
07.txt AC 3 ms 496 KB
08.txt AC 3 ms 496 KB
09.txt WA
10.txt AC 3 ms 496 KB
11.txt AC 3 ms 496 KB
12.txt AC 3 ms 496 KB
13.txt AC 4 ms 496 KB
14.txt AC 3 ms 496 KB
15.txt AC 3 ms 496 KB
16.txt AC 3 ms 496 KB
17.txt AC 3 ms 496 KB
18.txt AC 3 ms 496 KB
19.txt AC 3 ms 496 KB
20.txt AC 3 ms 496 KB
21.txt AC 3 ms 496 KB
22.txt AC 4 ms 496 KB
23.txt AC 3 ms 384 KB
24.txt AC 3 ms 496 KB
25.txt AC 2 ms 256 KB
26.txt WA
27.txt WA
28.txt WA
29.txt WA
30.txt AC 3 ms 496 KB
31.txt AC 2 ms 384 KB
32.txt WA
33.txt WA
34.txt WA
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB