結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 1 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 56 ms
5,376 KB
testcase_12 AC 184 ms
5,452 KB
testcase_13 AC 53 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 94 ms
5,376 KB
testcase_16 AC 86 ms
5,376 KB
testcase_17 AC 174 ms
5,376 KB
testcase_18 AC 129 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 172 ms
5,608 KB
testcase_21 AC 68 ms
5,376 KB
testcase_22 AC 30 ms
5,376 KB
testcase_23 AC 209 ms
5,772 KB
testcase_24 AC 208 ms
5,648 KB
testcase_25 AC 208 ms
5,772 KB
testcase_26 AC 208 ms
5,644 KB
testcase_27 AC 223 ms
5,644 KB
testcase_28 AC 167 ms
5,644 KB
testcase_29 AC 147 ms
5,776 KB
testcase_30 AC 214 ms
5,896 KB
testcase_31 AC 120 ms
5,772 KB
testcase_32 AC 216 ms
5,772 KB
testcase_33 AC 216 ms
5,776 KB
testcase_34 AC 164 ms
5,644 KB
testcase_35 AC 68 ms
5,772 KB
testcase_36 AC 74 ms
5,640 KB
testcase_37 AC 84 ms
5,768 KB
testcase_38 AC 66 ms
5,640 KB
testcase_39 AC 67 ms
5,772 KB
testcase_40 AC 72 ms
5,904 KB
testcase_41 WA -
testcase_42 AC 84 ms
5,768 KB
testcase_43 AC 83 ms
5,904 KB
testcase_44 AC 170 ms
5,772 KB
testcase_45 AC 217 ms
5,772 KB
testcase_46 AC 214 ms
5,772 KB
testcase_47 AC 176 ms
5,900 KB
testcase_48 AC 176 ms
5,644 KB
testcase_49 AC 215 ms
5,640 KB
testcase_50 AC 225 ms
5,640 KB
testcase_51 AC 213 ms
5,656 KB
testcase_52 AC 216 ms
5,904 KB
testcase_53 AC 197 ms
5,776 KB
testcase_54 AC 112 ms
5,896 KB
testcase_55 AC 114 ms
5,768 KB
testcase_56 AC 93 ms
5,644 KB
testcase_57 AC 73 ms
5,772 KB
testcase_58 AC 87 ms
5,900 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);
	}
	cout << c << endl;
}
0