結果

問題 No.2094 Symmetry
ユーザー MasKoaTSMasKoaTS
提出日時 2022-10-07 22:34:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,532 bytes
コンパイル時間 4,535 ms
コンパイル使用メモリ 268,892 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-09-03 13:54:59
合計ジャッジ時間 7,416 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 115 ms
7,680 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 123 ms
7,680 KB
testcase_33 AC 2 ms
4,500 KB
testcase_34 WA -
testcase_35 AC 71 ms
7,624 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <math.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define print(n) cout << (n) << endl
#define fprint(n) cout << setprecision(16) << (n) << endl
#define ceil_div(a, b) (((a) - 1) / (b) + 1)
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define itrep(itr, st) for (auto itr = st.begin(); itr != st.end(); itr++)
#define ite(i, a) for (auto& i : a)
#define all(x) x.begin(), x.end()
#define lb(A, x) (lower_bound(all(A), x) - A.begin())
#define ub(A, x) (upper_bound(all(A), x) - A.begin())
using str = string;
using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using Pair = pair<int, int>;
using mint = modint1000000007;
using Mint = modint998244353;
template <class T>	using V = vector<T>;
template <class T>	using VV = V<V<T> >;
template <class T>	using PQ = priority_queue<T, V<T>, greater<T> >;
template <class T>	using PQR = priority_queue<T>;
template <class T>	using BIT = fenwick_tree<T>;
const ll INF = 4611686018427387903;
const int inf = 2147483647;
const ll mod = 1000000007;
const ll MOD = 998244353;
template <class T>  inline V<T> getList(int n) { V<T> res(n); rep(i, 0, n) { cin >> res[i]; }return res; }
template <class T>  inline VV<T> getGrid(int m, int n) { VV<T> res(m, V<T>(n)); rep(i, 0, m) { res[i] = getList<T>(n); }return res; }
template <class T> inline void prints(V<T>& vec) { if (vec.size() == 0)return; cout << vec[0];	rep(i, 1, vec.size()) { cout << ' ' << vec[i]; } cout << '\n'; }
inline V<int> dtois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - '0'); } return vec; }
inline V<int> atois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - 'a'); } return vec; }
inline V<int> Atois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - 'A'); } return vec; }


int main(void) {
	int N, K;	cin >> N >> K;
	int N2 = N << 1;
	V<str> s = getList<str>(N2);
	VV<ll> c = getGrid<ll>(N2, N2);

	int black = 0;
	V<ll> score = {};
	rep(i, 0, N2) {
		rep(j, 0, N2) {
			score.push_back(c[i][j]);
			black += (s[i][j] == '#');
		}
	}
	sort(all(score));

	//シンメトリーを狙わない
	ll ans = 0;
	rep(i, 0, black) {
		ans += score[N2 * N2 - i - 1];
	}
	if (black & 1) {
		print(ans);
		return 0;
	}

	//シンメトリーを狙う
	ll ans2 = K;
	score = {};
	rep(i, 0, N2) {
		rep(j, 0, N) {
			score.push_back(c[i][j] + c[i][N2 - j - 1]);
		}
	}
	sort(all(score));
	rep(i, 0, black >> 1) {
		ans2 += score[N2 * N - i - 1];
	}
	ans = max(ans, ans2);
	print(ans);

	return 0;
}
0