QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357679#3276. 出题高手edisnimorFCompile Error//C++143.7kb2024-03-19 08:03:192024-03-19 08:03:19

Judging History

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

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

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];

bool operator >(const pii &x, const pii &y){
	return (i128)x.fr*y.sc>(i128)y.fr*x.sc;
}

vector<pii> q[N];

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

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(mx[j], cur);
			// ckmx(bmx[bel[j]], cur);
		}
		for(auto [l, id]:q[i]){
			ans[id]={0, 1};
			for(int j=l; j<=i; j++) ckmx(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;
}#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];

bool operator >(const pii &x, const pii &y){
	return (i128)x.fr*y.sc>(i128)y.fr*x.sc;
}

vector<pii> q[N];

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

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_ba<ck({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(mx[j], cur);
			// ckmx(bmx[bel[j]], cur);
		}
		for(auto [l, id]:q[i]){
			ans[id]={0, 1};
			for(int j=l; j<=i; j++) ckmx(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:80:2: error: stray ‘#’ in program
   80 | }#include<bits/stdc++.h>
      |  ^
answer.code: In function ‘int main()’:
answer.code:63:26: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   63 |                 for(auto [l, id]:q[i]){
      |                          ^
answer.code:72:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   72 |                 auto [a, b]=ans[i];
      |                      ^
answer.code: At global scope:
answer.code:80:3: error: ‘include’ does not name a type
   80 | }#include<bits/stdc++.h>
      |   ^~~~~~~
answer.code:91:6: error: redefinition of ‘template<class T> T rd()’
   91 | il T rd(){
      |      ^~
answer.code:12:6: note: ‘template<class T> T rd()’ previously declared here
   12 | il T rd(){
      |      ^~
answer.code:97:30: error: redefinition of ‘template<class T> void ckmx(T&, T)’
   97 | template<typename T> il void ckmx(T &x, T y){if(x<y) x=y;}
      |                              ^~~~
answer.code:18:30: note: ‘template<class T> void ckmx(T&, T)’ previously declared here
   18 | template<typename T> il void ckmx(T &x, T y){if(x<y) x=y;}
      |                              ^~~~
answer.code:98:30: error: redefinition of ‘template<class T> void ckmn(T&, T)’
   98 | template<typename T> il void ckmn(T &x, T y){if(y<x) x=y;}
      |                              ^~~~
answer.code:19:30: note: ‘template<class T> void ckmn(T&, T)’ previously declared here
   19 | template<typename T> il void ckmn(T &x, T y){if(y<x) x=y;}
      |                              ^~~~
answer.code:99:6: error: redefinition of ‘char _begin’
   99 | char _begin;
      |      ^~~~~~
answer.code:20:6: note: ‘char _begin’ previously declared here
   20 | char _begin;
      |      ^~~~~~
answer.code:103:11: error: redefinition of ‘const long long int N’
  103 | const int N=5e5+5, M=705;
      |           ^
answer.code:24:11: note: ‘const long long int N’ previously defined here
   24 | const int N=5e5+5, M=705;
      |           ^
answer.code:103:20: error: redefinition of ‘const long long int M’
  103 | const int N=5e5+5, M=705;
      |                    ^
answer.code:24:20: note: ‘const long long int M’ previously defined here
   24 | const int N=5e5+5, M=705;
      |                    ^
answer.code:105:5: error: redefinition of ‘long long int n’
  105 | int n, m, a[N];
      |     ^
answer.code:26:5: note: ‘long long int n’ previously declared here
   26 | int n, m, a[N];
      |     ^
answer.code:105:8: error: redefinition of ‘long long int m’
  105 | int n, m, a[N];
      |        ^
answer.code:26:8: note: ‘long long int m’ previously declared here
   26 | int n, m, a[N];
      |        ^
answer.code:105:11: error: redefinition of ‘long long int a [500005]’
  105 | int n, m, a[N];
      |           ^
answer.code:26:11: note: ‘long long int a [500005]’ previously declared here
   26 | int n, m, a[N];
      |           ^
answer.code:107:6: error: redefinition of ‘bool operator>(const std::pair<long long int, long long int>&, const std::pair<long long int, long long int>&)’
  107 | bool operator >(const pii &x, const pii &y){
      |      ^~~~~~~~
answer.code:28:6: note: ‘bool operator>(const std::pair<long long int, long long int>&, const std::pair<long long int, long long int>&)’ previously defined here
   28 | bool operator >(const pii &x, const pii &y){
      |      ^~~~~~~~
answer.code:111:13: error: redefinition of ‘std::vector<std::pair<long long int, long long int> > q [500005]’
  111 | vector<pii> q[N];
      |             ^
answer.code:32:13: note: ‘std::vector<std::pair<long long int, long long int> > q [500005]’ previously declared here
   32 | vector<pii> q[N];
      |             ^
answer.code:113:5: error: redefinition of ‘long long int B’
  113 | int B, bid, bel[N], lp[N], rp[N];
      |     ^
answer.code:34:5: note: ‘long long int B’ previously declared here
   34 | int B, bid, bel[N], lp[N], rp[N];
      |     ^
answer.code:113:8: error: redefinition of ‘long long int bid’
  113 | int B, bid, bel[N], lp[N], rp[N];
      |        ^~~
answer.code:34:8: note: ‘long long int bid’ previously declared here
   34 | int B, bid, bel[N], lp[N], rp[N];
      |        ^~~
answer.code:113:13: error: redefinition of ‘long long int bel [500005]’
  113 | int B, bid, bel[N], lp[N], rp[N];
      |             ^~~
answer.code:34:13: note: ‘long long int bel [500005]’ previously declared here
   34 | int B, bid, bel[N], lp[N], rp[N];
      |             ^~~
answer.code:113:21: error: redefinition of ‘long long int lp [500005]’
  113 | int B, bid, bel[N], lp[N], rp[N];
      |                     ^~
answer.code:34:21: note: ‘long long int lp [500005]’ previously declared here
   34 | int B, bid, bel[N], lp[N], rp[N];
      |                     ^~
answer.code:113:28: error: redefinition of ‘long long int rp [500005]’
  113 | int B, bid, bel[N], lp[N], rp[N];
      |              ...