QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395235#8601. Герої та МонстриNetwork_ErrorCompile Error//C++141.3kb2024-04-21 11:22:152024-04-21 11:22:15

Judging History

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

  • [2024-04-21 11:22:15]
  • 评测
  • [2024-04-21 11:22:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
//#define int long long
const int mod=998244353;
int power(int x,int y){
	int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int n,q,a[5010],b[5010],f[5010][5010],g[5010][5010],ans[5010];
void work(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	sort(a+1,a+n+1),sort(b+1,b+n+1);
	f[0][0]=g[n+1][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++){
			if(f[i-1][j])
			add(f[i][j],f[i-1][j]),
			add(f[i][j+1],(a[i]>b[j+1])*f[i-1][j]);
		}
	}
	for(int i=n;i;i--){
		for(int j=0;j<=n-i;j++){
			if(g[i+1][j])
			add(g[i][j],g[i+1][j]),
			add(g[i][j+1],(a[i]<b[n-j])*g[i+1][j]);
		}
	}
	for(int i=0,mid=0;i<=n;i++){
		while(mid<n&&a[mid+1]<=b[i])++mid;
		for(int k=i-mid+n;k<=mid;k++)
			add(ans[i],1ll*f[mid][k]*g[mid+1][(n-mid)-(i-k)]%mod);
	}
	cin>>q;
	while(q--){
		int l,r;ll x=0;cin>>l>>r;for(int i=l;i<=r;i++)x+=ans[i];cout<<x%mod<<'\n';
	}
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}


詳細信息

answer.code: In function ‘void work()’:
answer.code:44:25: error: ‘ll’ was not declared in this scope; did you mean ‘l’?
   44 |                 int l,r;ll x=0;cin>>l>>r;for(int i=l;i<=r;i++)x+=ans[i];cout<<x%mod<<'\n';
      |                         ^~
      |                         l
answer.code:44:63: error: ‘x’ was not declared in this scope
   44 |                 int l,r;ll x=0;cin>>l>>r;for(int i=l;i<=r;i++)x+=ans[i];cout<<x%mod<<'\n';
      |                                                               ^
answer.code:44:79: error: ‘x’ was not declared in this scope
   44 |                 int l,r;ll x=0;cin>>l>>r;for(int i=l;i<=r;i++)x+=ans[i];cout<<x%mod<<'\n';
      |                                                                               ^