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

Submission #1660043

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 = A+B;
	{
		auto ret1 = E(D);
		auto ret2 = F(ret1.second);
		auto ret3 = G(ret2.second);
		long long int x = 0;
		if( ret1.first == 0 ){
			x += B;
		}
		if( ret2.first == 0 ){
			x += A;
		}
			ans = max(ans, ret2.first / 2 * A + ret3 / 2 * max(A, B) + ret3 / 4 * min(A, B)+x);
		
	}
	{
		auto ret1 = F(D);
		auto ret2 = E(ret1.second);
		auto ret3 = G(ret2.second);
		long long int x = 0;
		if( ret1.first == 0 ){
			x += A;
		}
		if( ret2.first == 0 ){
			x += B;
		}
			ans = max(ans, ret2.first / 2 * B + ret3 / 2 * max(A, B) + ( ret3 / 4 * min(A, B) )+x);
		
		
	}
	cout << ans<< endl;
}

Submission

Task問題 D - 石
User nameユーザ名 031_goryudyuma
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1655 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 WA
02.txt WA
03.txt WA
04.txt WA
05.txt WA
06.txt WA
07.txt WA
08.txt WA
09.txt WA
10.txt AC 3 ms 496 KB
11.txt WA
12.txt WA
13.txt WA
14.txt WA
15.txt WA
16.txt WA
17.txt AC 3 ms 496 KB
18.txt AC 3 ms 496 KB
19.txt AC 3 ms 496 KB
20.txt WA
21.txt WA
22.txt WA
23.txt WA
24.txt WA
25.txt AC 2 ms 384 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 WA
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB