結果

問題 No.2276 I Want AC
ユーザー kabipoyokabipoyo
提出日時 2023-04-21 21:44:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,865 bytes
コンパイル時間 5,253 ms
コンパイル使用メモリ 255,844 KB
実行使用メモリ 6,028 KB
最終ジャッジ日時 2024-04-24 07:54:19
合計ジャッジ時間 33,579 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 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 252 ms
5,376 KB
testcase_12 AC 767 ms
5,580 KB
testcase_13 AC 241 ms
5,376 KB
testcase_14 AC 106 ms
5,376 KB
testcase_15 AC 407 ms
5,376 KB
testcase_16 AC 355 ms
5,376 KB
testcase_17 AC 714 ms
5,480 KB
testcase_18 AC 550 ms
5,376 KB
testcase_19 AC 20 ms
5,376 KB
testcase_20 AC 712 ms
5,736 KB
testcase_21 AC 307 ms
5,376 KB
testcase_22 AC 139 ms
5,376 KB
testcase_23 AC 882 ms
5,772 KB
testcase_24 AC 882 ms
5,772 KB
testcase_25 AC 886 ms
5,772 KB
testcase_26 AC 834 ms
5,772 KB
testcase_27 AC 907 ms
6,028 KB
testcase_28 AC 705 ms
5,644 KB
testcase_29 AC 612 ms
5,772 KB
testcase_30 AC 891 ms
5,900 KB
testcase_31 AC 500 ms
5,644 KB
testcase_32 AC 903 ms
5,896 KB
testcase_33 AC 892 ms
5,772 KB
testcase_34 AC 665 ms
5,648 KB
testcase_35 AC 277 ms
5,644 KB
testcase_36 AC 318 ms
5,648 KB
testcase_37 AC 279 ms
5,772 KB
testcase_38 AC 277 ms
5,768 KB
testcase_39 AC 277 ms
5,900 KB
testcase_40 AC 311 ms
5,908 KB
testcase_41 WA -
testcase_42 AC 278 ms
5,772 KB
testcase_43 AC 278 ms
5,776 KB
testcase_44 AC 743 ms
5,772 KB
testcase_45 AC 900 ms
5,900 KB
testcase_46 AC 886 ms
5,644 KB
testcase_47 AC 752 ms
5,772 KB
testcase_48 AC 753 ms
5,772 KB
testcase_49 AC 900 ms
5,772 KB
testcase_50 AC 909 ms
5,640 KB
testcase_51 AC 888 ms
5,900 KB
testcase_52 AC 894 ms
5,772 KB
testcase_53 AC 815 ms
5,772 KB
testcase_54 AC 458 ms
5,776 KB
testcase_55 AC 474 ms
5,772 KB
testcase_56 AC 391 ms
5,772 KB
testcase_57 AC 292 ms
5,896 KB
testcase_58 AC 353 ms
5,644 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-100, ok+100) {
		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