結果
| 問題 |
No.3366 Reversible Tile:Revival
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-14 18:02:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,502 bytes |
| コンパイル時間 | 4,177 ms |
| コンパイル使用メモリ | 269,416 KB |
| 実行使用メモリ | 20,616 KB |
| 最終ジャッジ日時 | 2025-11-17 20:46:35 |
| 合計ジャッジ時間 | 14,541 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 WA * 5 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
using mint = atcoder::modint998244353;
using ull = unsigned long long;
void solve() {
ll n, m;
cin >> n >> m;
vector<ll> l(m), r(m);
rep(i, 0, m) cin >> l[i] >> r[i], l[i]--;
vector<ll> cv = {0, n};
rep(i, 0, m) {
cv.push_back(l[i]);
cv.push_back(r[i]);
}
sort(cv.begin(), cv.end());
cv.erase(unique(cv.begin(), cv.end()), cv.end());
int k = cv.size();
auto get_ith = [&](ll x) {
return lower_bound(cv.begin(), cv.end(), x) - cv.begin();
};
vector<ull> im(k);
{
random_device rd;
mt19937_64 mt(rd());
rep(i, 0, m) {
int nl = get_ith(l[i]);
int nr = get_ith(r[i]);
ull hs = mt();
im[nl] = hs;
im[nr] = hs;
}
}
map<ull, mint> mp;
rep(i, 0, k - 1) {
mp[im[i]] += cv[i + 1] - cv[i];
im[i + 1] ^= im[i];
}
mint ans = 0;
{
mint tmp = mp[0] + (n - mp[0]) / 2;
ans += tmp * tmp;
mp.erase(0);
}
for (auto [hs, ad] : mp) {
ans += ad * ad / 4;
}
ans *= mint(2).pow(m);
cout << ans.val() << '\n';
}
int main() {
int t = 1;
// cin >> t;
while (t--) solve();
}