QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357701#3276. 出题高手edisnimorFCompile Error//C++141.8kb2024-03-19 08:28:142024-03-19 08:28:14

Judging History

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

  • [2024-03-19 08:28:14]
  • 评测
  • [2024-03-19 08:28:14]
  • 提交

answer

#include<bits/stdc++.h>
#define il inline
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pii pair<int, int>
#define fr first
#define sc second
#define ll long long
#define mset(f, z) memset(f, z, sizeof(f))
#define mcpy(f, g) memcpy(f, g, sizeof(g))
using namespace std;
template<typename T=ll>
il T rd(){
	T s=0; bool f=1; char c=getchar();
	while(!isdigit(c)) f^=(c=='-'), c=getchar();
	while(isdigit(c)) s=s*10+c-'0', c=getchar();
	return f? s:-s;
}
template<typename T> il void ckmx(T &x, T y){if(x<y) x=y;}
template<typename T> il void ckmn(T &x, T y){if(y<x) x=y;}
char _begin;
#define int ll
#define i128 __int128

const int N=5e5+5, M=705;

int n, m, a[N];

void upd(pii &x, pii y){
	if(x.fr*1./x.sc<y.fr*1./y.sc) x=y;
}

vector<pii> q[N];

int B, bid, bel[N], lp[N], rp[N];
pii mx[N], bmx[M], ans[N];

int gcd(int a, int b){
	if(!b) return a;
	return gcd(b, a%b);
}

char _end;
signed main(){
	debug("%lfMB\n", (&_end-&_begin)/1024./1024.);

	n=rd();
	for(int i=1; i<=n; i++) a[i]=rd();
	m=rd();
	for(int i=1; i<=m; i++){
		int l=rd(), r=rd();
		q[r].push_back({l, i});
	}
	B=sqrt(n);
	for(int i=1; i<=n; i++){
		bid=bel[i]=(i-1)/B+1;
		mx[i]={0, 1};
		if(!lp[bid]) lp[bid]=i, bmx[bid]={0, 1};
		rp[bid]=i;
	}
	//sweep
	for(int i=1; i<=n; i++){
		for(int j=i, sum=0; j>0; j--){
			sum+=a[j];
			pii cur={sum*sum, i-j+1};ckmx
			ans[id]={0, 1};
			for(int j=l; j<=i; j++) upd(ans[id], mx[j]);
			// for(int j=bel[l]+1; j<bel[i]; j++) ckmx(ans[id], bmx[j]);
			// for(int j=l; j<=min(rp[bel[l]], i); j++) ckmx(ans[id], mx[j]);
			// if(bel[l]!=bel[i]) for(int j=lp[bel[i]]; j<=i; j++) ckmx(ans[id], mx[j]);
		}
	}
	for(int i=1; i<=m; i++){
		auto [a, b]=ans[i];
		if(!a) puts("0 1");
		else{
			int gc=gcd(a, b);
			printf("%lld %lld\n", a/gc, b/gc);
		}
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:64:54: error: expected ‘;’ before ‘ans’
   64 |                         pii cur={sum*sum, i-j+1};ckmx
      |                                                      ^
      |                                                      ;
   65 |                         ans[id]={0, 1};
      |                         ~~~                           
answer.code:65:39: error: statement cannot resolve address of overloaded function
   65 |                         ans[id]={0, 1};
      |                                       ^
answer.code:66:35: error: ‘l’ was not declared in this scope
   66 |                         for(int j=l; j<=i; j++) upd(ans[id], mx[j]);
      |                                   ^
answer.code:66:57: error: ‘id’ was not declared in this scope; did you mean ‘i’?
   66 |                         for(int j=l; j<=i; j++) upd(ans[id], mx[j]);
      |                                                         ^~
      |                                                         i
answer.code:73:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   73 |                 auto [a, b]=ans[i];
      |                      ^