답안 #301761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301761 2020-09-18T07:35:36 Z CSQ31 Boat (APIO16_boat) C++14
31 / 100
574 ms 524292 KB
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 1e6+1e5;
ll bit[MAXN];
void upd(int pos,ll val){
	for(int i=pos;i<MAXN;i+=i&(-i)){
		bit[i]+=val;
		bit[i]%=MOD;
	}
}
ll query(int pos){
	ll res=0;
	for(int i=pos;i>0;i-=i&(-i)){
		res+=bit[i];
		res%=MOD;
	}
	return res;
}
ll a[550];
ll b[550];
int main()
{
	int n;
	cin>>n;
	vector<ll>coords;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		for(int j=a[i];j<=b[i];j++)coords.pb(j);
	}
	int sz = coords.size();
	sort(all(coords));
	coords.resize(unique(all(coords))-coords.begin());
	map<int,int>mp;
	//cout<<sz<<'\n';
	for(int i=0;i<sz;i++){
		mp[coords[i]] = i+1;
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=b[i];j>=a[i];j--){
			int p = mp[j];
			ll res = query(p-1);
			res%=MOD;
			upd(p,res+1);
		}
	}
	for(int i=1;i<=sz;i++){
		ans+=query(i)-query(i-1);
		ans%=MOD;
	}
	cout<<ans%MOD;;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 280 ms 14288 KB Output is correct
22 Correct 290 ms 14160 KB Output is correct
23 Correct 267 ms 13456 KB Output is correct
24 Correct 301 ms 14672 KB Output is correct
25 Correct 304 ms 15012 KB Output is correct
26 Correct 287 ms 15696 KB Output is correct
27 Correct 297 ms 15824 KB Output is correct
28 Correct 285 ms 15696 KB Output is correct
29 Correct 295 ms 15952 KB Output is correct
30 Correct 554 ms 62288 KB Output is correct
31 Correct 574 ms 61216 KB Output is correct
32 Correct 558 ms 62416 KB Output is correct
33 Correct 551 ms 60752 KB Output is correct
34 Correct 558 ms 61264 KB Output is correct
35 Correct 529 ms 58448 KB Output is correct
36 Correct 551 ms 60496 KB Output is correct
37 Correct 559 ms 61264 KB Output is correct
38 Correct 532 ms 59216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 459 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 280 ms 14288 KB Output is correct
22 Correct 290 ms 14160 KB Output is correct
23 Correct 267 ms 13456 KB Output is correct
24 Correct 301 ms 14672 KB Output is correct
25 Correct 304 ms 15012 KB Output is correct
26 Correct 287 ms 15696 KB Output is correct
27 Correct 297 ms 15824 KB Output is correct
28 Correct 285 ms 15696 KB Output is correct
29 Correct 295 ms 15952 KB Output is correct
30 Correct 554 ms 62288 KB Output is correct
31 Correct 574 ms 61216 KB Output is correct
32 Correct 558 ms 62416 KB Output is correct
33 Correct 551 ms 60752 KB Output is correct
34 Correct 558 ms 61264 KB Output is correct
35 Correct 529 ms 58448 KB Output is correct
36 Correct 551 ms 60496 KB Output is correct
37 Correct 559 ms 61264 KB Output is correct
38 Correct 532 ms 59216 KB Output is correct
39 Runtime error 459 ms 524292 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -