QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#357687 | #3276. 出题高手 | edisnimorF | Compile Error | / | / | C++14 | 1.4kb | 2024-03-19 08:20:15 | 2024-03-19 08:20:15 |
Judging History
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;
}
pii f[N][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();
for(int i=1; i<=n; i++){
int sum=0;
for(int j=i; j<=n; j++){
sum+=a[j];
f[i][j]={sum, j-i+1};
}
}
for(int l=n; l; l--){
for(int r=l+1; r<=n; r++){
ckmx(f[l][r], f[l][r-1]);
ckmx(f[l][r], f[l+1][r]);
}
}
m=rd();
for(int i=1; i<=m; i++){
int l=rd(), r=rd();
auto [a, b]=f[l][r];
if(!a) puts("0 1");
else{
int gc=gcd(a, b);
printf("%d %d\n", a/gc, b/gc);
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:61:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 61 | auto [a, b]=f[l][r]; | ^ answer.code:65:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::tuple_element<0, std::pair<long long int, long long int> >::type’ {aka ‘long long int’} [-Wformat=] 65 | printf("%d %d\n", a/gc, b/gc); | ~^ ~~~~ | | | | int std::tuple_element<0, std::pair<long long int, long long int> >::type {aka long long int} | %lld answer.code:65:37: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::tuple_element<1, std::pair<long long int, long long int> >::type’ {aka ‘long long int’} [-Wformat=] 65 | printf("%d %d\n", a/gc, b/gc); | ~^ ~~~~ | | | | int std::tuple_element<1, std::pair<long long int, long long int> >::type {aka long long int} | %lld /tmp/cc4HVoxs.o: in function `main': answer.code:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `_begin' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `_end' defined in .bss section in answer answer.code:(.text.startup+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x6f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x10c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x630): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x78b): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc4HVoxs.o answer.code:(.text.startup+0x7d3): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc4HVoxs.o collect2: error: ld returned 1 exit status