# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
588368 | messiuuuuu | Boat (APIO16_boat) | C++17 | 604 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define task "C"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 5;
const int MOD = 1e9 + 7;
int n;
int a[MAXN], b[MAXN];
vector<int> num;
void Input()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
for (int j = a[i]; j <= b[i]; j++)
num.pb(j);
}
}
void NenSo()
{
sort(num.begin(), num.end());
num.erase(unique(num.begin(), num.end()), num.end());
}
int nen(int x)
{
return lower_bound(num.begin(), num.end(), x) - num.begin() + 1;
}
struct BIT
{
vector<int> fe;
int sz;
void Init(int _sz)
{
sz = _sz;
fe.resize(sz + 1, 0);
}
void add(int id, int val)
{
for (; id <= sz; id += id & -id)
{
fe[id] += val;
fe[id] %= MOD;
}
}
int get(int l)
{
int res = 0;
for (; l; l -= l & -l)
{
res += fe[l];
res %= MOD;
}
return res;
}
};
void Solve()
{
NenSo();
BIT bit;
bit.Init(num.size());
for (int i = 1; i <= n; i++)
{
for (int j = b[i]; j >= a[i]; j--)
{
bit.add(nen(j), (bit.get(nen(j) - 1) + 1) % MOD);
}
}
cout << bit.get(num.size());
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(task".INP","r"))
{
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
Input();
Solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |