QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93858#2. Boatushg8877Compile Error//C++142.5kb2023-04-03 11:52:222023-04-03 11:52:23

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 11:52:23]
  • 评测
  • [2023-04-03 11:52:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
const int MAXN=1005;
const int MOD=1e9+7;
int n,m;
int l[MAXN],r[MAXN];
int len[MAXN];
ll f[MAXN][MAXN],C[MAXN][MAXN];
vector<int> ve;
ll inv(ll a,int b=MOD-2){ll res=1;while(b){if(b&1)res=res*a%MOD;a=a*a%MOD,b>>=1;}return res;}
void init(){
	for(int i=1;i<m;i++){
		C[i][0]=1;
		for(int j=1;j<=n;j++)
			C[i][j]=C[i][j-1]*(len[i]+j-1)%MOD*inv(j)%MOD;
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		ve.push_back(l[i]),ve.push_back(r[i]+1);
	}
	sort(ve.begin(),ve.end());
	ve.erase(unique(ve.begin(),ve.end()),ve.end());
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(ve.begin(),ve.end(),l[i])-ve.begin()+1;
		r[i]=lower_bound(ve.begin(),ve.end(),r[i]+1)-ve.begin();
	}
	m=ve.size();
	for(int i=1;i<m;i++)
		len[i]=ve[i]-ve[i-1];
	init();
	for(int i=0;i<MAXN;i++) f[0][i]=1;
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=l[i];j<=r[i];j++){
			int cnt=0;
			for(int k=i-1;k>=0;k--){
				if(l[k+1]<=j&&r[k+1]>=j) cnt++;
				f[i][j]+=C[j][cnt]*f[k][j-1]%MOD;
			}
			f[i][j]%=MOD;
			ans+=f[i][j];
		}
		for(int j=1;j<=m;j++)
			f[i][j]+=f[i][j-1],f[i][j]%=MOD;
	}
	cout<<ans%MOD<<endl;
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
const int MAXN=1005;
const int MOD=1e9+7;
int n,m;
int l[MAXN],r[MAXN];
int len[MAXN];
ll f[MAXN][MAXN],C[MAXN][MAXN];
vector<int> ve;
ll inv(ll a,int b=MOD-2){ll res=1;while(b){if(b&1)res=res*a%MOD;a=a*a%MOD,b>>=1;}return res;}
void init(){
	for(int i=1;i<m;i++){
		C[i][0]=1;
		for(int j=1;j<=n;j++)
			C[i][j]=C[i][j-1]*(len[i]+j-1)%MOD*inv(j)%MOD;
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		ve.push_back(l[i]),ve.push_back(r[i]+1);
	}
	sort(ve.begin(),ve.end());
	ve.erase(unique(ve.begin(),ve.end()),ve.end());
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(ve.begin(),ve.end(),l[i])-ve.begin()+1;
		r[i]=lower_bound(ve.begin(),ve.end(),r[i]+1)-ve.begin();
	}
	m=ve.size();
	for(int i=1;i<m;i++)
		len[i]=ve[i]-ve[i-1];
	init();
	for(int i=0;i<MAXN;i++) f[0][i]=1;
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=l[i];j<=r[i];j++){
			int cnt=0;
			for(int k=i-1;k>=0;k--){
				if(l[k+1]<=j&&r[k+1]>=j) cnt++;
				f[i][j]+=C[j][cnt]*f[k][j-1]%MOD;
			}
			f[i][j]%=MOD;
			ans+=f[i][j];
		}
		for(int j=1;j<=m;j++)
			f[i][j]+=f[i][j-1],f[i][j]%=MOD;
	}
	cout<<ans%MOD<<endl;
	return 0;
}

详细

answer.code:60:11: error: redefinition of ‘const int MAXN’
   60 | const int MAXN=1005;
      |           ^~~~
answer.code:5:11: note: ‘const int MAXN’ previously defined here
    5 | const int MAXN=1005;
      |           ^~~~
answer.code:61:11: error: redefinition of ‘const int MOD’
   61 | const int MOD=1e9+7;
      |           ^~~
answer.code:6:11: note: ‘const int MOD’ previously defined here
    6 | const int MOD=1e9+7;
      |           ^~~
answer.code:62:5: error: redefinition of ‘int n’
   62 | int n,m;
      |     ^
answer.code:7:5: note: ‘int n’ previously declared here
    7 | int n,m;
      |     ^
answer.code:62:7: error: redefinition of ‘int m’
   62 | int n,m;
      |       ^
answer.code:7:7: note: ‘int m’ previously declared here
    7 | int n,m;
      |       ^
answer.code:63:5: error: redefinition of ‘int l [1005]’
   63 | int l[MAXN],r[MAXN];
      |     ^
answer.code:8:5: note: ‘int l [1005]’ previously declared here
    8 | int l[MAXN],r[MAXN];
      |     ^
answer.code:63:13: error: redefinition of ‘int r [1005]’
   63 | int l[MAXN],r[MAXN];
      |             ^
answer.code:8:13: note: ‘int r [1005]’ previously declared here
    8 | int l[MAXN],r[MAXN];
      |             ^
answer.code:64:5: error: redefinition of ‘int len [1005]’
   64 | int len[MAXN];
      |     ^~~
answer.code:9:5: note: ‘int len [1005]’ previously declared here
    9 | int len[MAXN];
      |     ^~~
answer.code:65:4: error: redefinition of ‘long long int f [1005][1005]’
   65 | ll f[MAXN][MAXN],C[MAXN][MAXN];
      |    ^
answer.code:10:4: note: ‘long long int f [1005][1005]’ previously declared here
   10 | ll f[MAXN][MAXN],C[MAXN][MAXN];
      |    ^
answer.code:65:18: error: redefinition of ‘long long int C [1005][1005]’
   65 | ll f[MAXN][MAXN],C[MAXN][MAXN];
      |                  ^
answer.code:10:18: note: ‘long long int C [1005][1005]’ previously declared here
   10 | ll f[MAXN][MAXN],C[MAXN][MAXN];
      |                  ^
answer.code:66:13: error: redefinition of ‘std::vector<int> ve’
   66 | vector<int> ve;
      |             ^~
answer.code:11:13: note: ‘std::vector<int> ve’ previously declared here
   11 | vector<int> ve;
      |             ^~
answer.code:67:4: error: redefinition of ‘long long int inv(long long int, int)’
   67 | ll inv(ll a,int b=MOD-2){ll res=1;while(b){if(b&1)res=res*a%MOD;a=a*a%MOD,b>>=1;}return res;}
      |    ^~~
answer.code:12:4: note: ‘long long int inv(long long int, int)’ previously defined here
   12 | ll inv(ll a,int b=MOD-2){ll res=1;while(b){if(b&1)res=res*a%MOD;a=a*a%MOD,b>>=1;}return res;}
      |    ^~~
answer.code:68:6: error: redefinition of ‘void init()’
   68 | void init(){
      |      ^~~~
answer.code:13:6: note: ‘void init()’ previously defined here
   13 | void init(){
      |      ^~~~
answer.code:76:5: error: redefinition of ‘int main()’
   76 | int main(){
      |     ^~~~
answer.code:21:5: note: ‘int main()’ previously defined here
   21 | int main(){
      |     ^~~~