답안 #69279

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69279 2018-08-20T11:10:55 Z FedericoS Boat (APIO16_boat) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

ll M=1000000007;
int N;
ll X[505],Y[505];
map<ll,ll> S;
map<pll,ll> DP;
ll ans;
unordered_map<ll,ll> R;

ll query(ll k, ll l, ll r, ll a, ll b){

	if(b<l or r<a) return 0;
	if(a<=l and r<=b) return R[k];

	ll m=(l+r)/2;
	return (query(2*k,l,m,a,b)+query(2*k+1,m+1,r,a,b))%M;

}

void insert(ll k, ll l, ll r, ll a, ll b){

	if(l==r) R[k]=(R[k]+b)%M;
	else{

		ll m=(l+r)/2;
		if(a<=m)
			insert(2*k,l,m,a,b);
		else
			insert(2*k+1,m+1,r,a,b);
		R[k]=(R[2*k]+R[2*k+1])%M;

	}

}

ll somma(ll a){
	return query(1,0,M,a,M-1);
}

void aggiungi(ll a, ll b){
	insert(1,0,M,a,b);
}

int main(){

	cin>>N;
	for(int i=0;i<N;i++)
		cin>>X[i]>>Y[i];

	for(int i=N-1;i>=0;i--)
		for(ll j=X[i];j<=Y[i];j++){
			DP[{i,j}]=(somma(j+1)+1)%M;
			aggiungi(j,DP[{i,j}]);
			ans=(ans+DP[{i,j}])%M;
			//cout<<i<<" "<<j<<" "<<DP[{i,j}]<<endl;
		}

	//for(int i=0;i<10;i++)cout<<i<<" "<<S[i]<<endl;

	cout<<ans;

}
/*
3
1 1
2 2
3 3
*/

Compilation message

boat.cpp:13:1: error: 'unordered_map' does not name a type
 unordered_map<ll,ll> R;
 ^~~~~~~~~~~~~
boat.cpp: In function 'll query(ll, ll, ll, ll, ll)':
boat.cpp:18:27: error: 'R' was not declared in this scope
  if(a<=l and r<=b) return R[k];
                           ^
boat.cpp: In function 'void insert(ll, ll, ll, ll, ll)':
boat.cpp:27:11: error: 'R' was not declared in this scope
  if(l==r) R[k]=(R[k]+b)%M;
           ^
boat.cpp:35:3: error: 'R' was not declared in this scope
   R[k]=(R[2*k]+R[2*k+1])%M;
   ^