結果

問題 No.2875 What is My Rank?
ユーザー nana
提出日時 2024-09-20 09:24:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,383 bytes
コンパイル時間 3,323 ms
コンパイル使用メモリ 185,152 KB
最終ジャッジ日時 2025-02-24 09:42:46
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 27
権限があれば一括ダウンロードができます

ソースコード

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

#include<iostream>
#include<sstream>
#include<algorithm>
#include<deque>
#include<list>
#include<map>
#include<memory>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<string.h>
#include<string>
#include<math.h>
#include<float.h>
#include<stdio.h>
#include<vector>
#include<iomanip>
#include<bitset>
#include<random>
#include<complex>
#include <cassert>
#include <utility>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T &a, T b) { return ((a>b) ? (a = b, true) : (false));}
#define rep(i,s,n) for(long long i=s;i<(long long)(n);i++)
#define rrep(i,s,n) for(long long i=n-1;i>=s;i--)
const long long inf = 1LL<<60;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//pairsecondsort(p.begin(),p.end(),cmp)
#define cmp [](pair<ll,ll> a, pair<ll,ll> b){return a.second<b.second;}
//cmpArg := , atan2l(y, x); atan2l(y, x) = [-pi, pi]
#define cmpArg [](const auto &p1, const auto &p2) { return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first); }
typedef pair<long long, long long> P;
typedef pair<ll, pair<ll,ll> > PP;
#define rll ll,vector<ll>,greater<ll>
#define rP P,vector<P>,greater<P>
const long double pi = 3.14159265358979;
typedef unsigned long long ull;
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vmint vector<mint>
#define vvmint vector<vector<mint>>
#define vvch vector<vector<char>>
#define vch vector<char>
#define vstring vector<string>
#define rPP PP,vector<PP>,greater<PP>
#define vP vector<P>
#define vvP vector<vector<P>>
#define vPP vector<PP>
#define all(x) x.begin(), x.end()
//UNIQUE(x) x
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
int pc(ll x) { return __builtin_popcount(x); } //1 pop count
//lower_bound(調)`ll index = lower_bound(all(inv), -a[i], greater<ll>()) - inv.begin();`,
    lis
//a > inf - b a > inf / b
//(siz+1)/2
//using mint = atcoder::modint, mainmint::set_mod(M)modmint
//map auto it = mp.lower_bound(key)lower_bound使 while(it != mp.end())
//!!
using mint = modint998244353;
int main()
{
int n; cin >> n;
vector<ll> l(n), r(n);
rep(i,0,n) cin >> l[i] >> r[i];
mint ans = 0;
rep(j,1,n) {
if(r[0] < l[j]) { ans += 1; continue; }
else if(r[j] < l[0]) { ans += 0; continue; }
else if (r[0] >= l[j]) {
mint len = r[0] - l[j] + 1;
mint tmp = mint(r[0] - l[0] + 1) * (r[j] - l[j] + 1) - len*(len+1)/2;
ans += tmp / ((r[0] - l[0] + 1) * (r[j] - l[j] + 1));
}
else if(l[0] <= r[j]) {
mint len = r[j] - l[0];
ans += len*(len-1)/2 / ((r[0] - l[0] + 1) * (r[j] - l[j] + 1));
}
}
ans++;
cout << ans.val() << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0