Submission #1659848


Source Code Expand

Copy
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1000000007;
const long double big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint H,W,i,j;cin>>H>>W;
	llint A,B;cin>>A>>B;
	llint yo=0,ta=0,ze=0,da=0,ka=0;
	vector<string>a(H);
	for(i=0;i<H;i++){cin>>a[i];}
	for(i=0;i<H/2;i++){
		for(j=0;j<W/2;j++){
			if(a[i][j]=='.'&&a[H-i-1][j]=='.'&&a[i][W-j-1]=='.'&&a[H-i-1][W-j-1]=='.'){
				continue;
			}
			bool yoko=false,tate=false;
			yoko= a[i][j]==a[i][W-j-1]&&a[H-i-1][j]==a[H-i-1][W-j-1];
			tate= a[i][j]==a[H-i-1][j]&&a[i][W-j-1]==a[H-i-1][W-j-1];
			int kazu=0;
			if(a[i][j]=='S'){kazu++;}
			if(a[H-i-1][j]=='S'){kazu++;}
			if(a[i][W-j-1]=='S'){kazu++;}
			if(a[H-i-1][W-j-1]=='S'){kazu++;}
			if(yoko&&tate){ze++;}
			if((!yoko)&&tate){ta++;}
			if(yoko&&(!tate)){yo++;}
			if(kazu==3){ka++;}
			else if((!yoko)&&(!tate)){da++;}
		}
	}
	llint ans=0;
	ans+=A+B;
	if(ta==0&&da==0&&ka==0){ans-=B;}
	if(yo==0&&da==0&&ka==0){ans-=A;}
	ans+=ze*(A+B+max(A,B));
	ans+=max((ka+yo)*B,(ka+ta)*A);
	//cerr<<yo<<" "<<ta<<" "<<ze<<" "<<da<<endl;
	cout<<ans<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - 石
User WA_TLE
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2191 Byte
Status
Exec Time 3 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 600 / 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
Case Name Status Exec Time Memory
01.txt 3 ms 256 KB
02.txt 3 ms 256 KB
03.txt 3 ms 256 KB
04.txt 3 ms 256 KB
05.txt 3 ms 256 KB
06.txt 3 ms 256 KB
07.txt 3 ms 256 KB
08.txt 3 ms 256 KB
09.txt 3 ms 256 KB
10.txt 3 ms 256 KB
11.txt 3 ms 256 KB
12.txt 3 ms 256 KB
13.txt 3 ms 256 KB
14.txt 3 ms 256 KB
15.txt 3 ms 256 KB
16.txt 3 ms 256 KB
17.txt 3 ms 256 KB
18.txt 3 ms 256 KB
19.txt 3 ms 256 KB
20.txt 3 ms 256 KB
21.txt 3 ms 256 KB
22.txt 3 ms 256 KB
23.txt 3 ms 256 KB
24.txt 3 ms 256 KB
25.txt 2 ms 256 KB
26.txt 3 ms 256 KB
27.txt 3 ms 256 KB
28.txt 3 ms 256 KB
29.txt 3 ms 256 KB
30.txt 3 ms 256 KB
31.txt 2 ms 256 KB
32.txt 3 ms 256 KB
33.txt 3 ms 256 KB
34.txt 3 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB