結果

問題 No.2276 I Want AC
ユーザー kabipoyokabipoyo
提出日時 2023-04-21 21:43:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,859 bytes
コンパイル時間 4,621 ms
コンパイル使用メモリ 256,096 KB
実行使用メモリ 5,904 KB
最終ジャッジ日時 2024-04-24 07:52:28
合計ジャッジ時間 12,480 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 55 ms
5,376 KB
testcase_12 AC 184 ms
5,580 KB
testcase_13 AC 54 ms
5,376 KB
testcase_14 AC 24 ms
5,376 KB
testcase_15 AC 96 ms
5,376 KB
testcase_16 AC 87 ms
5,376 KB
testcase_17 AC 170 ms
5,376 KB
testcase_18 AC 127 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 163 ms
5,608 KB
testcase_21 AC 68 ms
5,376 KB
testcase_22 AC 31 ms
5,376 KB
testcase_23 AC 210 ms
5,900 KB
testcase_24 AC 207 ms
5,644 KB
testcase_25 AC 206 ms
5,644 KB
testcase_26 AC 199 ms
5,772 KB
testcase_27 AC 218 ms
5,900 KB
testcase_28 AC 165 ms
5,904 KB
testcase_29 AC 142 ms
5,776 KB
testcase_30 AC 209 ms
5,772 KB
testcase_31 AC 117 ms
5,768 KB
testcase_32 AC 211 ms
5,776 KB
testcase_33 AC 212 ms
5,648 KB
testcase_34 AC 153 ms
5,776 KB
testcase_35 AC 71 ms
5,772 KB
testcase_36 AC 68 ms
5,772 KB
testcase_37 AC 77 ms
5,772 KB
testcase_38 AC 71 ms
5,772 KB
testcase_39 AC 71 ms
5,772 KB
testcase_40 AC 70 ms
5,896 KB
testcase_41 WA -
testcase_42 AC 77 ms
5,776 KB
testcase_43 AC 77 ms
5,648 KB
testcase_44 AC 177 ms
5,776 KB
testcase_45 AC 209 ms
5,648 KB
testcase_46 AC 208 ms
5,772 KB
testcase_47 AC 185 ms
5,772 KB
testcase_48 AC 184 ms
5,768 KB
testcase_49 AC 211 ms
5,776 KB
testcase_50 AC 218 ms
5,640 KB
testcase_51 AC 207 ms
5,772 KB
testcase_52 AC 209 ms
5,768 KB
testcase_53 AC 189 ms
5,900 KB
testcase_54 AC 108 ms
5,772 KB
testcase_55 AC 110 ms
5,644 KB
testcase_56 AC 92 ms
5,772 KB
testcase_57 AC 74 ms
5,648 KB
testcase_58 AC 80 ms
5,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N;
	string S;
	cin >> N >> S;

	lint a=0, b=0, c=0, x, y, z;
	lint ng = -1, m1, m2, ok = N;
	while (abs(ok - ng) > 2) {
		m1 = (ok + ng*2) / 3;
		m2 = (ok*2 + ng) / 3;
		rep(_, 2) {
			string t;
			rep(i, N) {
				if (S[i] == '?') {
					if (i < m1) t += 'A';
					else t += 'C';
				} else {
					t += S[i];
				}
			}
			vi v(N);
			rep(i, N) {
				if (t[N-1-i] == 'C') v[N-1-i]++;
			}
			rep(i, N-1) v[N-2-i] += v[N-1-i];
			a = 0;
			rep(i, N) {
				if (t[i] == 'A') a += v[i];
			}
			swap(a, b);
			swap(m1, m2);
		}
		if (a < b) ng = m1;
		else ok = m2;
		chmax(c, a);
		chmax(c, b);
	}
	repx(j, ng, ok+1) {
		string t;
		rep(i, N) {
			if (S[i] == '?') {
				if (i < j) t += 'A';
				else t += 'C';
			} else {
				t += S[i];
			}
		}
		vi v(N);
		rep(i, N) {
			if (t[N-1-i] == 'C') v[N-1-i]++;
		}
		rep(i, N-1) v[N-2-i] += v[N-1-i];
		a = 0;
		rep(i, N) {
			if (t[i] == 'A') a += v[i];
		}
		chmax(c, a);
	}
	cout << c << endl;
}
0