結果

問題 No.292 芸名
ユーザー marurunn11marurunn11
提出日時 2020-10-28 22:30:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 20,764 bytes
コンパイル時間 4,129 ms
コンパイル使用メモリ 233,496 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-21 22:26:18
合計ジャッジ時間 5,185 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 1 ms
6,820 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"
#ifdef _MSC_VER
#include <intrin.h> //gcc__popcnt, umul128 include
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#pragma warning(disable : 4996)
#pragma intrinsic(_umul128)
#endif
//#include <atcoder/all>
//using namespace atcoder;
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int long long
#define double long double
#define LL128 boost::multiprecision::int128_t
#define LL boost::multiprecision::cpp_int
#define LD100 boost::multiprecision::cpp_dec_float_100
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((ld) (d), 0.50)
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
const int INF = std::numeric_limits<int>::max() / 2 - 100000000;
const long long INF2 = std::numeric_limits<long long>::max() / 2 - 100000000;
const ld pi = acos(-1);
//constexpr int MOD = 1000000007; //1e9 + 7
//constexpr int MOD = 1000000009; //1e9 + 9
constexpr int MOD = 998244353; // 7 * 17 * 2^23 + 1
long long my_gcd(long long a, long long b) {
if (b == 0) return a;
return my_gcd(b, a % b);
}
// ax + by = gcd(a, b) gcd(a, b)
long long my_gcd_ext(long long a, long long b, long long& x, long long& y) {
if (b == 0) {
x = 1; y = 0;
return a;
}
long long tempo = my_gcd_ext(b, a % b, y, x);
//bx' + ry' = gcd(a, b) → (qb + r)x + by = gcd(a, b) // (r = a % b)
//b(x' - qy') + (bq + r)y' = gcd(a, b)
// x = y', y = x' - qy'
y -= (a / b) * x;
return tempo;
}
//M a gcd(a, M) = 1
long long my_invmod(long long a, long long M) {
long long x = 0, y = 0;
long long memo = my_gcd_ext(a, M, x, y);
assert(memo == 1LL);
x %= M;
if (x < 0) x += M;
return x;
}
//2
//N^aM
ll my_pow(ll N, ll a, ll M) {
ll tempo;
if (a == 0) {
return 1;
}
else {
if (a % 2 == 0) {
tempo = my_pow(N, a / 2, M);
return (tempo * tempo) % M;
}
else {
tempo = my_pow(N, a - 1, M);
return (tempo * N) % M;
}
}
}
ll my_pow(ll N, ll a) {
ll tempo;
if (a == 0) {
return 1;
}
else {
if (a % 2 == 0) {
tempo = my_pow(N, a / 2);
return (tempo * tempo);
}
else {
tempo = my_pow(N, a - 1);
return (tempo * N);
}
}
}
//N_C_a M
ll my_combination(ll N, ll a, ll M) {
if (N < a) return 0;
ll answer = 1;
rep(i, a) {
answer *= (N - i);
answer %= M;
}
rep(i, a) {
answer *= my_pow(i + 1, M - 2, M);
answer %= M;
}
return answer;
}
//N_C_i M v.at(i)
void my_combination_table(ll N, ll M, vector<ll>& v) {
v.assign(N + 1, 1);
for (ll i = 1; i <= N; i++) {
v.at(i) = v.at(i - 1) * (N - (i - 1LL));
v.at(i) %= M;
v.at(i) *= my_invmod(i, M);
v.at(i) %= M;
}
}
//(N + i)_C_N M v.at(i) (v )
void my_combination_table2(ll N, ll M, vector<ll>& v) {
v.at(0) = 1;
for (ll i = 1; i < (ll)v.size(); i++) {
v.at(i) = v.at(i - 1) * (N + i);
v.at(i) %= M;
v.at(i) *= my_invmod(i, M);
v.at(i) %= M;
}
}
//x ! dp 20 ! = 2.43e18 long long
ll factorial(ll x, vector<ll>& dp) {
if ((ll)dp.size() <= x) {
int n = dp.size();
rep(i, x + 1 - n) {
dp.push_back(0);
}
}
if (x == 0) return dp.at(x) = 1;
if (dp.at(x) != -1 && dp.at(x) != 0) return dp.at(x);
return dp.at(x) = x * factorial(x - 1, dp);
}
// M x ! dp
ll factorial2(ll x, ll M, vector<ll>& dp) {
if ((ll)dp.size() <= x) {
int n = dp.size();
rep(i, x + 1 - n) {
dp.push_back(0);
}
}
if (x == 0) return dp.at(x) = 1;
if (dp.at(x) != -1 && dp.at(x) != 0) return dp.at(x);
ll tempo = (x * factorial2(x - 1, M, dp));
tempo %= M;
return dp.at(x) = tempo;
}
// mod M (M: prime)x ! dp
ll factorial_inverse(ll x, ll M, vector<ll>& dp) {
if ((ll)dp.size() <= x) {
int n = dp.size();
rep(i, x + 1 - n) {
dp.push_back(0);
}
}
if (x == 0) return dp.at(x) = 1;
if (dp.at(x) != -1 && dp.at(x) != 0) return dp.at(x);
return dp.at(x) = (my_pow(x, M - 2, M) * factorial_inverse(x - 1, M, dp)) % M;
}
//N_C_a M
ll my_combination2(ll N, ll a, ll M, vector<ll>& dp_factorial, vector<ll>& dp_factorial_inverse) {
if ((ll)dp_factorial.size() <= N) {
factorial2(N, M, dp_factorial);
}
if ((ll)dp_factorial_inverse.size() <= N) {
factorial_inverse(N, M, dp_factorial_inverse);
}
if (N < a) return 0;
ll answer = 1;
answer *= dp_factorial.at(N);
answer %= M;
answer *= dp_factorial_inverse.at(N - a);
answer %= M;
answer *= dp_factorial_inverse.at(a);
answer %= M;
return answer;
}
// base n iv.at(i) ( n )
void ll_to_vector(signed base, long long n, vector<signed>& v) {
long long tempo = n;
long long tempo2 = n;
signed n_digit = 1;
while (tempo2 >= base) {
tempo2 /= base;
n_digit++;
}
v.assign(n_digit, 0); // v 調
// n_digit = v.size(); // v
for (signed i = 0; i < n_digit; i++) {
long long denominator = my_pow(base, n_digit - 1 - i);
v.at(i) = tempo / denominator;
tempo -= v.at(i) * denominator;
}
}
int char_to_int(char c) {
switch (c) {
case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9;
default: return 0;
}
}
//prime false O(n loglog n)
void prime_judge(vector<bool>& prime_or_not) {
prime_or_not.assign(prime_or_not.size(), true);
prime_or_not.at(0) = false;
prime_or_not.at(1) = false;
long long n = prime_or_not.size() - 1;
for (long long i = 2; 2 * i <= n; i++) {
prime_or_not.at(2 * i) = false;
}
for (long long i = 3; i * i <= n; i += 2) {
//i false
if (prime_or_not.at(i)) {
long long j = i * i; // i^2 i false
while (j < n + 1) {
prime_or_not.at(j) = false;
j += 2 * i;
}
}
}
};
// n + 1 vector res.at(i) i 1 res.at(i) == i i
// 2e8 3.2 prime_judge 3
vector<long long> sieve(long long n) {
n++; // n +1
vector<long long> res(n, 0);
for (long long i = 1; i < n; i++) {
if (i % 2 == 0) res.at(i) = 2; //
else res.at(i) = i;
}
for (long long i = 3; i * i < n; i += 2) {
//i i
if (res.at(i) == i) {
long long j = i * i; // i^2 i
while (j < n) {
if (res.at(j) == j) res.at(j) = i;
j += 2 * i;
}
}
}
return res;
};
//O (sqrt(n))
bool is_prime(long long N) {
if (N == 1 || N == 0) return false;
if (N == 2 || N == 3) return true;
if (N % 2 == 0) return false;
if (N % 3 == 0) return false;
for (long long i = 1; (6 * i + 1) * (6 * i + 1) <= N; ++i) {
if (N % (6 * i + 1) == 0) return false;
}
for (long long i = 0; (6 * i + 5) * (6 * i + 5) <= N; ++i) {
if (N % (6 * i + 5) == 0) return false;
}
return true;
}
// O(sqrt(N))
map<ll, ll> divide_to_prime(int target) {
map<ll, ll> res;
//sqrt(target) 調
ll upper_lim = ceil(sqrt(target));
vector<bool> prime_or_not(upper_lim + 3, true);
if (upper_lim < 20) prime_or_not.assign(25, true);
prime_or_not.at(0) = false; prime_or_not.at(1) = false;
prime_judge(prime_or_not);
ll tempo = target;
for (int i = 1; i * i <= target; i++) {
if (prime_or_not.at(i)) {
while (tempo % i == 0) {
tempo /= i;
res[i]++;
}
}
if (tempo == 1) break; //
}
if (tempo != 1) res[tempo]++; //sqrt(target) 1
return res;
}
// sieve vector min_factor
map<long long, long long> divide_to_prime2(long long target, vector<long long>& min_factor) {
map<long long, long long> res;
if (min_factor.empty() || (long long)min_factor.size() - 1 < target) min_factor = sieve(target);
while (target > 1) {
res[min_factor[target]]++;
target /= min_factor[target];
}
return res;
}
// O(sqrt(N))
vector<long long> count_dividers(long long target) {
vector <long long> dividers, tempo;
long long i = 1;
while (i * i < target + 1) {
if (target % i == 0) {
dividers.push_back(i);
if (i < target / i) tempo.push_back(target / i); // ifsqrt(target)
}
i++;
}
for (long long j = 0; j < (long long)tempo.size(); j++) {
dividers.push_back(tempo.at(tempo.size() - 1 - j));
}
return dividers;
}
// sieve vector min_factor
vector<long long> count_dividers2(long long target, vector<long long>& min_factor) {
vector <long long> dividers = { 1 };
map<long long, long long> memo = divide_to_prime2(target, min_factor);
for (auto&& iter = memo.begin(); iter != memo.end(); iter++) {
vector <long long> tempo = dividers;
for (long long k = 0; k < (long long)tempo.size(); k++) {
long long times = 1;
for (long long j = 1; j <= (iter->second); j++) {
times *= iter->first;
dividers.push_back(tempo[k] * times);
}
}
}
sort(dividers.begin(), dividers.end()); //sort
return dividers;
}
void BFS_labyrinth(queue<pair<int, int>>& que, vector<vector<int>>& dist, int& area) {
int H = dist.size();
int W = dist.at(0).size();
while (!que.empty()) {
int h, w;
pair<int, int> tempo = que.front(); que.pop();
h = tempo.first;
w = tempo.second;
//cout << temp_i << " " << temp_j << endl;
for (int dh = -1; dh <= 1; dh++) {
for (int dw = -1; dw <= 1; dw++) {
if (h + dh < 0 || H <= h + dh) continue; //
if (w + dw < 0 || W <= w + dw) continue; //
if (dh == 0 && dw == 0) continue; //
if (dh * dw != 0) continue; //
if (dist.at(h + dh).at(w + dw) != -1) continue; // INF ok
dist.at(h + dh).at(w + dw) = dist.at(h).at(w) + 1;
que.push(make_pair(h + dh, w + dw));
}
}
//
if (que.empty()) {
rep(i, H) {
rep(j, W) {
if (dist.at(i).at(j) == -1) {
que.push(make_pair(i, j));
dist.at(i).at(j) = 0;
area++;
break;
}
}
if (!que.empty()) break;
}
}
}
}
void BFS01_labyrinth(deque<pair<int, int>>& que, vector<vector<int>>& dist, vector<vector<int>>& cost) {
int H = dist.size();
int W = dist.at(0).size();
while (!que.empty()) {
int h, w;
pair<int, int> tempo = que.front(); que.pop_front();
h = tempo.first;
w = tempo.second;
//cout << temp_i << " " << temp_j << endl;
for (int dh = -1; dh <= 1; dh++) {
for (int dw = -1; dw <= 1; dw++) {
if (h + dh < 0 || H <= h + dh) continue; //
if (w + dw < 0 || W <= w + dw) continue; //
if (dh == 0 && dw == 0) continue; //
if (dh * dw != 0) continue; //
if (dist.at(h + dh).at(w + dw) != -1) continue; // INF ok
dist.at(h + dh).at(w + dw) = dist.at(h).at(w) + cost.at(h + dh).at(w + dw);
if (cost.at(h + dh).at(w + dw) == 0) {//
que.push_front(make_pair(h + dh, w + dw));
}
else {//
que.push_back(make_pair(h + dh, w + dw));
}
}
}
}
}
void dfs(const vector<vector<int>>& G, vector<bool>& seen, int v) {
seen.at(v) = true;
for (int next_v : G.at(v)) {
if (seen.at(next_v)) continue;
dfs(G, seen, next_v);
}
}
class edge {
public:
int to;
int cost;
};
void dijkstra(int s, const vector<vector<edge>> G, vector<int>& dist) {
int V = dist.size(); //
dist.assign(V, INF);
//first second
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
dist.at(s) = 0; que.push(make_pair(0, s));
while (!que.empty()) {
pair<int, int> p = que.top(); que.pop();
int v = p.second;
if (dist.at(v) < p.first) continue; //
for (int i = 0; i < (int)G.at(v).size(); i++) {
edge e = G.at(v).at(i);
//for (auto&& e : G.at(v)) { // ←
if (dist.at(e.to) > dist.at(v) + e.cost) {
dist.at(e.to) = dist.at(v) + e.cost;
que.push(make_pair(dist.at(e.to), e.to));
}
}
}
}
class Edge {
public:
int from;
int to;
int cost;
};
vector<int> BellmanFord(const int s, vector<int>& dist, vector<Edge> G) {
const int V = dist.size();
vector<int> res; //
//
dist.assign(V, INF);
dist.at(s) = 0;
for (int i = 0; i < V; i++) {
for (int j = 0; j < (int)G.size(); j++) {
Edge e = G.at(j);
if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) { //
dist[e.to] = dist[e.from] + e.cost;
if (i == V - 1) { //
res.push_back(e.to);
//return true;
}
}
}
}
return res;
//return false;
}
const int Vmax2 = 1;
int dp_warshall[Vmax2][Vmax2];
//G.at(i).at(j) i j
void warshall_floyd(const int V, const vector<vector<int>> G) {
rep(i, V) {
rep(j, V) {
dp_warshall[i][j] = G.at(i).at(j); //
}
}
rep(k, V) {
rep(i, V) {
rep(j, V) {
dp_warshall[i][j] = min(dp_warshall[i][j], dp_warshall[i][k] + dp_warshall[k][j]);
}
}
}
}
class UnionFind {
public:
vector<int> parent;
vector<int> rank;
vector<int> v_size;
UnionFind(int N) : parent(N), rank(N, 0), v_size(N, 1) {
rep(i, N) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) return x;
return parent[x] = root(parent[x]); //
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry) return; //xy
if (rank[rx] < rank[ry]) {
parent[rx] = ry;
v_size[ry] += v_size[rx];
}
else {
parent[ry] = rx;
v_size[rx] += v_size[ry];
if (rank[rx] == rank[ry]) rank[rx]++;
}
}
bool same(int x, int y) {
return (root(x) == root(y));
}
int count_tree() {
int N = parent.size();
int res = 0;
rep(i, N) {
if (root(i) == i) res++;
}
return res;
}
int size(int x) {
return v_size[root(x)];
}
};
class wUnionFind {
public:
vector<int> parent;
vector<int> diff_weight; //
vector<int> rank;
wUnionFind(int N) : parent(N), diff_weight(N, 0), rank(N, 0) {
rep(i, N) {
parent.at(i) = i;
}
}
int root(int x) {
if (parent.at(x) == x) return x;
int r = root(parent.at(x));
diff_weight.at(x) += diff_weight.at(parent.at(x)); //
return parent.at(x) = r;
}
//x
int weight(int x) {
root(x);
return diff_weight.at(x);
}
//weight.at(y) - weight.at(x) == w
bool unite(int x, int y, int w) {
int rx = root(x);
int ry = root(y);
int diff_weight_to_ry_from_rx = w + weight(x) - weight(y);
if (rx == ry) return false; //xy
if (rank.at(rx) < rank.at(ry)) {
parent.at(rx) = ry;
diff_weight.at(rx) = -diff_weight_to_ry_from_rx;
}
else {
parent.at(ry) = rx;
diff_weight.at(ry) = diff_weight_to_ry_from_rx;
if (rank.at(rx) == rank.at(ry)) rank.at(rx)++;
}
return true;
}
bool same(int x, int y) {
return (root(x) == root(y));
}
int count_tree() {
int N = parent.size();
int res = 0;
rep(i, N) {
if (root(i) == i) res++;
}
return res;
}
};
//
ld calc_dist(int x1, int y1, int x2, int y2) {
int tempo = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
ld res = sqrt((ld)tempo);
return res;
}
class doubling {
private:
//maxN
int maxN = 1;
int logmaxN = 1;
int maxV = 1;
public:
//next[i][v] → v 2^i
//next[i][v] = next[i - 1][next[i - 1][v]];
vector<vector<int>> next;
vector<vector<int>> sum;
//
doubling(int _maxN, int _maxV) : maxN(_maxN), maxV(_maxV) { initialize0(); };
doubling(int _maxV) : doubling(INF, _maxV) {};
doubling(int _maxN, vector<int> next0) : maxN(_maxN), maxV((int)next0.size()) { initialize(next0); };
doubling(vector<int> next0) : doubling(INF, next0) {};
void initialize0() {
while ((1LL << logmaxN) < maxN) logmaxN++;
next.assign(logmaxN + 1, vector<int>(maxV));
sum.assign(logmaxN + 1, vector<int>(maxV));
}
void initialize(vector<int> next0) {
while ((1LL << logmaxN) < maxN) logmaxN++;
next.assign(logmaxN + 1, vector<int>(maxV));
sum.assign(logmaxN + 1, vector<int>(maxV));
rep(v, maxV) next[0][v] = next0[v];
rep(v, maxV) sum[0][v] = v; //[v, v + 1) v
for (int i = 1; i <= logmaxN; i++) {
rep(v, maxV) {
next[i][v] = next[i - 1][next[i - 1][v]];
}
}
for (int i = 1; i <= logmaxN; i++) {
rep(v, maxV) {
sum[i][v] = sum[i - 1][v] + sum[i - 1][next[i - 1][v]];
}
}
}
//v N get(v, 0) = v (0-indexed)
int get(int v, int N) {
int logN = 1;
while ((1LL << logN) < N) logN++; //
//M = next.size(); // = logmaxN;
int now = v;
for (int i = 0; i <= logN; i++) {
if (N & (int)(1LL << i)) {
now = next.at(i).at(now);
}
}
return now;
}
//v N get_sum(v, 0) = v (0-indexed)
int get_sum(int v, int N) {
N++; //1-indexed (get_sum(v, 1) = v, get_sum(v, 0) = 0) 0-indexed
int logN = 1;
while ((1LL << logN) < N) logN++; //
//M = next.size(); // = logmaxN;
int now = v;
int res = 0;
for (int i = 0; i <= logN; i++) {
if (N & (int)(1LL << i)) {
res += sum.at(i).at(now);
now = next.at(i).at(now);
}
}
return res;
}
};
//
vector<pair<int, char>> RunLength(string S) {
int N = S.size();
vector<pair<int, char>> memo;
if (N == 1) {
memo.push_back(MP(1, S.at(0)));
return memo;
}
int tempo = 1;
for (int i = 1; i < N; i++) {
if (i != N - 1) {
if (S.at(i) == S.at(i - 1)) tempo++;
else {
memo.push_back(MP(tempo, S.at(i - 1)));
tempo = 1;
}
}
else {
if (S.at(i) == S.at(i - 1)) {
tempo++;
memo.push_back(MP(tempo, S.at(i - 1)));
}
else {
memo.push_back(MP(tempo, S.at(i - 1)));
memo.push_back(MP(1, S.at(i)));
}
}
}
return memo;
}
void printf_ld(ld res) {
printf("%.12Lf\n", res);
//cout << std::fixed << std::setprecision(12) << res << endl;
}
signed main() {
string S; cin >> S;
int t, u;
cin >> t >> u;
int N = S.size();
rep(i, N) if (i != t && i != u) cout << S.at(i);
cout << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0