結果
| 問題 | No.3847 Triple Balls Removal |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-05 04:41:58 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 5,658 bytes |
| 記録 | |
| コンパイル時間 | 6,208 ms |
| コンパイル使用メモリ | 418,004 KB |
| 実行使用メモリ | 27,032 KB |
| 最終ジャッジ日時 | 2026-12-04 21:00:47 |
| 合計ジャッジ時間 | 17,597 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 29 |
ソースコード
// This solution should be TLE!
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#pragma GCC target("avx2,bmi2,popcnt,lzcnt")
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
const ll INF = 4e18;
using ld = long double;
const ld INFD = INFINITY;
const ld EPS = LDBL_EPSILON;
template<class T, class Comp = less<T>> using p_que = priority_queue<T, vector<T>, Comp>;
array sin90 = { 0, 1, 0, -1 }, cos90 = { 1, 0, -1, 0 };
array sin45 = { 0, 1, 1, 1, 0, -1, -1, -1 }, cos45 = { 1, 1, 0, -1, -1, -1, 0, 1 };
#define p1 first
#define p2 second
#define reps(i, l, r) for (decay_t<decltype(r)> i##_right = (r), i = (l); i < i##_right; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, l, r) for (decay_t<decltype(r)> i##_left = (l), i = (r) - 1; i >= i##_left; --i)
#define rrep(i, n) rreps(i, 0, n)
#define all(a) begin(a), end(a)
#define sz(a) ll(ssize(a))
template <typename T> inline constexpr bool is_pair_v = false;
template <typename T, typename U> inline constexpr bool is_pair_v<pair<T, U>> = true;
bool chmin(auto& a, auto b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, auto b) { return a < b ? a = b, 1 : 0; }
string int128_to_str(__int128_t target) {
string target_str;
__uint128_t target_tmp = target < 0 ? -target : target;
do { target_str += '0' + target_tmp % 10; target_tmp /= 10; } while (target_tmp != 0);
if (target < 0) target_str += '-';
reverse(target_str.begin(), target_str.end());
return target_str;
}
template<int m> struct nyaan_static_modint : atcoder::static_modint<m> {
using base = atcoder::static_modint<m>;
using base::base;
nyaan_static_modint() = default;
nyaan_static_modint(const base &x) : base(x) {}
static constexpr unsigned int get_mod() { return m; }
unsigned int get() const { return base::val(); }
nyaan_static_modint inverse() const { return base::inv(); }
};
#ifdef DEBUG
#include <cxxabi.h>
template <typename T> inline string get_typename(size_t length_limit = string::npos) {
string name = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, nullptr);
if (name.length() > length_limit) name = name.substr(0, length_limit - 3) + "...";
return name;
}
template <typename T> string to_pretty_str(T target) {
string str;
if constexpr (is_void_v<T>) str += "void"s;
else if constexpr (is_null_pointer_v<T>) str += "null"s;
else if constexpr (is_same_v<T, bool>) str += target ? "true"s : "false"s;
else if constexpr (is_same_v<T, char> || is_same_v<T, char16_t> || is_same_v<T, char32_t> || is_same_v<T, wchar_t>) str += "'"s + target + "'"s;
else if constexpr (atcoder::internal::is_modint<T>::value) str += to_string(target.val()) + "(mod)"s;
else if constexpr (is_arithmetic_v<T>) {
if constexpr (is_same_v<T, __int128_t>) str += int128_to_str(target);
else if (target >= INF) str += "INF"s;
else if constexpr (is_signed_v<T>) if (target <= -INF) str = "-INF"s;
else str += to_string(target);
} else if constexpr (is_pair_v<T>) str += "("s + to_pretty_str(target.first) + ", "s + to_pretty_str(target.second) + ")"s;
else if constexpr (is_convertible_v<T, string>) str += "\""s + target + "\""s;
else if constexpr (is_array_v<T>) {
str += "["s;
bool separate = false;
for (const auto &target_i : target) { if (separate) str += ", "s; str += to_pretty_str(target_i); separate = true; }
str += "]"s;
} else if constexpr (is_same_v<decltype(begin(declval<T>())), decltype(end(declval<T>()))>) {
str += "("s + get_typename<T>(20) + "){"s;
bool separate = false;
for (const auto &target_i : target) { if (separate) str += ","s; str += " "s + to_pretty_str(target_i); separate = true; }
if (separate) str += " "s;
str += "}"s;
} else str += "<"s + get_typename<T>(20) + " ("s + to_string(sizeof(target)) + " byte)>"s;
return str;
}
template <typename F> void debug_txt_f(F callback, int line = -1, string file = (__FILE__)) {
string dump_str = "[DEBUG] ";
if (line >= 0) {
dump_str += "(";
if (file != (__FILE__)) dump_str += file + ":";
dump_str += "L" + to_string(line) + ") ";
}
dump_str += callback();
cerr << dump_str << endl;
}
# define debug_txt(txt) (debug_txt_f([&]() { return to_pretty_str(txt); }, (__LINE__), (__FILE__)), true)
template <typename... Types>
void dump_f(string labels, tuple<Types...> targets_tupl, int line = -1, string file = (__FILE__)) {
debug_txt_f([=]() {
string txt;
apply([labels, &txt](auto... targets) {
int i = 0, label_left = 0;
(([&](auto target) {
const auto label_len = labels.find(',', label_left) - label_left;
if (i >= 1) txt += ", ";
txt += regex_replace(labels.substr(label_left, label_len), regex("^\\s+|\\s+$"), "") + ": " + to_pretty_str(target);
label_left += label_len + 1;
++i;
})(targets), ...);
txt += ";";
}, targets_tupl);
return txt;
}, line, file);
}
# define dump(...) (dump_f((#__VA_ARGS__), make_tuple(__VA_ARGS__), (__LINE__), (__FILE__)), true)
#else
# define debug_txt(...) (false)
# define dump(...) (false)
#endif
// ================================ ANSWER ================================
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(12);
ll n;
cin>>n;
auto a=vector<ll>(n);
rep(i,n) {
cin>>a[i];
}
while (true) {
auto na=vector<ll>();
for (auto i=0LL;i<sz(a);++i) {
if (i+2<sz(a)&&a[i]==a[i+1]&&a[i+1]==a[i+2]) i+=2;
else na.emplace_back(a[i]);
}
if (sz(na)==sz(a)) break;
a.swap(na);
}
cout<<(n-sz(a))<<'\n';
}