提出 #73691188
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fix(x) fixed << setprecision(x)
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define repe(i, start, end) for (auto i = (start); (i) <= (end); (i)++)
#define rrep(i, start, end) for (auto i = (start); (i) >= (end); (i)--)
constexpr auto PI = 3.14159265358979;
constexpr int INF = 1e+9;
constexpr long long INFL = 1e+18;
using ll = long long;
using lld = long double;
// using mint = modint1000000007;
using mint = modint998244353;
using Pair_int = pair<int, int>;
using Pair_ll = pair<ll, ll>;
template <class T>
using Graph = vector<vector<T>>;
template <class T1, class T2>
inline auto div_floor(T1 a, T2 b)
{
if (b < 0)
a *= -1, b *= -1;
if (a >= 0)
return a / b;
else
return (a + 1) / b - 1;
}
template <class T1, class T2>
inline auto div_ceil(T1 a, T2 b)
{
if (b < 0)
a *= -1, b *= -1;
if (a <= 0)
return a / b;
else
return (a - 1) / b + 1;
}
ll floor_sqrt(ll x)
{
ll y = sqrt(x);
while (y * y > x)
y--;
while ((y + 1) * (y + 1) <= x)
y++;
return y;
}
ll pow_int(ll x, ll n)
{
ll res = 1;
while (n > 0)
{
if (n & 1)
res *= x;
x *= x;
n >>= 1;
}
return res;
}
ll pow_mod(ll x, ll n, ll mod)
{
ll res = 1;
while (n > 0)
{
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll gcd(ll x, ll y)
{
if (x < y)
swap(x, y);
ll r;
while (y > 0)
{
r = x % y;
x = y;
y = r;
}
return x;
}
ll lcm(ll x, ll y) { return ll(x / gcd(x, y)) * y; }
ll nCk(ll n, ll r)
{
if (r < 0 || n < r)
return 0;
ll ans = 1;
for (ll i = 1; i <= r; i++)
{
ans *= n--;
ans /= i;
}
return ans;
}
int get_rand(int seed, int min, int max)
{
static mt19937_64 mt64(seed);
uniform_int_distribution<int> get_rand_int(min, max);
return get_rand_int(mt64);
}
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T1, class T2>
inline auto mod(T1 x, T2 r) { return (x % r + r) % r; }
// ======================================== //
int main()
{
string S, T;
cin >> S >> T;
vector<int> s_a_cnts, t_a_cnts;
string s_no_a, t_no_a;
int cnt_s = 0, cnt_t = 0;
for (char c : S)
{
if (c == 'A')
{
cnt_s++;
}
else
{
s_no_a += c;
s_a_cnts.push_back(cnt_s);
cnt_s = 0;
}
}
s_a_cnts.push_back(cnt_s);
for (char c : T)
{
if (c == 'A')
{
cnt_t++;
}
else
{
t_no_a += c;
t_a_cnts.push_back(cnt_t);
cnt_t = 0;
}
}
t_a_cnts.push_back(cnt_t);
if (s_no_a != t_no_a)
{
cout << -1 << endl;
return 0;
}
int ans = 0;
rep(i, 0, s_a_cnts.size())
{
ans += abs(s_a_cnts[i] - t_a_cnts[i]);
}
cout << ans << endl;
return 0;
}
提出情報
提出日時
2026-02-28 21:19:04+0900
問題
C - Insert and Erase A
ユーザ
Yuulis
言語
C++23 (GCC 15.2.0)
得点
300
コード長
3433 Byte
結果
AC
実行時間
13 ms
メモリ
8744 KiB
コンパイルエラー
./Main.cpp: In function 'int main()':
./Main.cpp:12:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | #define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
| ~~~~^~~~~~~
./Main.cpp:168:5: note: in expansion of macro 'rep'
168 | rep(i, 0, s_a_cnts.size())
| ^~~
ジャッジ結果
セット名
Sample
All
得点 / 配点
0 / 0
300 / 300
結果
セット名
テストケース
Sample
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt, 04_handmade_08.txt, 04_handmade_09.txt
ケース名
結果
実行時間
メモリ
00_sample_00.txt
AC
1 ms
3604 KiB
00_sample_01.txt
AC
1 ms
3648 KiB
00_sample_02.txt
AC
1 ms
3512 KiB
00_sample_03.txt
AC
1 ms
3604 KiB
01_random_00.txt
AC
4 ms
4668 KiB
01_random_01.txt
AC
5 ms
4964 KiB
01_random_02.txt
AC
13 ms
8712 KiB
02_random2_00.txt
AC
8 ms
6428 KiB
02_random2_01.txt
AC
10 ms
4488 KiB
02_random2_02.txt
AC
12 ms
7512 KiB
02_random2_03.txt
AC
12 ms
7012 KiB
02_random2_04.txt
AC
10 ms
6256 KiB
02_random2_05.txt
AC
7 ms
4660 KiB
02_random2_06.txt
AC
10 ms
6912 KiB
02_random2_07.txt
AC
6 ms
4240 KiB
02_random2_08.txt
AC
10 ms
5124 KiB
02_random2_09.txt
AC
11 ms
5560 KiB
02_random2_10.txt
AC
10 ms
6892 KiB
02_random2_11.txt
AC
11 ms
7348 KiB
03_random3_00.txt
AC
12 ms
8504 KiB
03_random3_01.txt
AC
9 ms
5348 KiB
03_random3_02.txt
AC
10 ms
6760 KiB
03_random3_03.txt
AC
11 ms
6140 KiB
04_handmade_00.txt
AC
1 ms
3588 KiB
04_handmade_01.txt
AC
1 ms
3468 KiB
04_handmade_02.txt
AC
1 ms
3648 KiB
04_handmade_03.txt
AC
1 ms
3468 KiB
04_handmade_04.txt
AC
13 ms
8744 KiB
04_handmade_05.txt
AC
11 ms
6548 KiB
04_handmade_06.txt
AC
11 ms
6584 KiB
04_handmade_07.txt
AC
9 ms
4328 KiB
04_handmade_08.txt
AC
5 ms
3948 KiB
04_handmade_09.txt
AC
5 ms
3904 KiB