#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
int n,aa,bb;
map<int,int> dd;
int si[2001];
llo mod=1000000007;
vector<int> cc;
vector<pair<int,int>> it;
int fac[501];
void comp(){
fac[0]=1;
for(int i=1;i<501;i++){
fac[i]=fac[i-1]*i;
fac[i]%=mod;
}
}
int pre[2001][501];
int pre2[2001][501];
int com[501][501];
int ind2=0;
int mod2(int ee,int ff){
if(ff==0){
return 1;
}
int ans=mod2(ee,ff/2);
ans*=ans;
ans%=mod;
if(ff%2==1){
ans*=ee;
ans%=mod;
}
return ans;
}
void ncr(){
for(int i=1;i<n+1;i++){
for(int j=0;j<=i;j++){
com[i][j]=mod2(fac[j],mod-2)*mod2(fac[i-j],mod-2);
com[i][j]%=mod;
com[i][j]*=fac[i];
com[i][j]%=mod;
}
}
}
void comp2(){
fac[0]=1;
for(int i=0;i<ind2;i++){
int cur=1;
pre[i][0]=0;
for(int j=1;j<n+1;j++){
if(j<=si[i]){
cur*=mod2(j,mod-2);
cur%=mod;
cur*=(si[j]-j+1);
cur%=mod;
pre[i][j]=cur;
pre[i][j]+=pre[i][j-1];
pre[i][j]%=mod;
}
else{
pre[i][j]=pre[i][j-1];
}
}
}
for(int i=0;i<ind2;i++){
for(int j=1;j<n+1;j++){
pre2[i][j]=0;
for(int k=1;k<=j;k++){
pre2[i][j]+=pre[i][k]*com[j-1][k-1];
pre2[i][j]%=mod;
}
}
}
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>aa>>bb;
cc.pb(aa);
cc.pb(bb);
it.pb({aa,bb});
}
comp();//factorial
ncr();//computing iCj for i and j from 1 to n
sort(cc.begin(),cc.end());
for(int i=0;i<cc.size();i++){
if(i<cc.size()-1 and cc[i]==cc[i+1]){
continue;
}
dd[cc[i]]=ind2;
ind2+=1;
si[dd[cc[i]]]=1;
if(i<cc.size()-1){
if(cc[i]<cc[i+1]+1){
si[ind2]=cc[i+1]-cc[i]-1;
ind2+=1;
}
}
}
comp2();
/* for(int i=0;i<n;i++){
it[i].a=it[ab[i].a];
it[i].b=it[ab[i].b];
}
*/
return 0;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:93:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<cc.size();i++){
~^~~~~~~~~~
boat.cpp:94:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(i<cc.size()-1 and cc[i]==cc[i+1]){
~^~~~~~~~~~~~
boat.cpp:100:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(i<cc.size()-1){
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
844 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
844 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
2168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
844 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |