| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 730753 | bgnbvnbv | Boat (APIO16_boat) | C++14 | 396 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=(int)1e9+7;
const int maxn=505;
int sz,a[maxn],b[maxn];
vector<int>v,s;
int bit[1000005];
void update(int pos,int val)
{
while(pos<=sz)
{
bit[pos]+=val;
if(bit[pos]>=mod) bit[pos]-=mod;
pos+=pos&(-pos);
}
}
int get(int pos)
{
int ans=0;
while(pos>0)
{
ans+=bit[pos];
if(ans>=mod) ans-=mod;
pos-=(pos&(-pos));
}
return ans;
}
int n;
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++)
{
cin >> a[i] >> b[i];
for(int j=a[i];j<=b[i];j++) v.push_back(j);
}
sort(v.begin(),v.end());
s.push_back(-1);
s.push_back(0);
for(int i=0;i<v.size();i++)
{
if(i==0||v[i]!=v[i-1]) s.push_back(v[i]);
}
swap(v,s);
sz=v.size()-1;
update(1,1);
for(int i=1;i<=n;i++)
{
int l=lower_bound(v.begin(),v.end(),a[i])-v.begin();
int r=lower_bound(v.begin(),v.end(),b[i])-v.begin();
for(int j=r;j>=l;j--)
{
update(j,get(j-1));
}
}
cout << (get(sz)-1+mod)%mod;
}
컴파일 시 표준 에러 (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... | ||||
