QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#374952 | #5433. Absolute Difference | huzhaoyang | Compile Error | / | / | C++14 | 1.9kb | 2024-04-02 19:56:01 | 2024-04-02 19:56:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef __int128 LL;
typedef pair<int,int> pii;
const int N=100005;
int n,m;
ll nn,mm;
LL ans;
pii a[N],b[N];
struct Data{
ll P;LL E;
Data operator + (const Data &n)const{
return Data{P+n.P,E+n.E};
}
double operator - (const Data &n)const{
return E*n.P-P*n.E;
}
}sa,sb,Sa,Sb;
ll sqr(int k){
return (ll)k*k;
}
LL cube(int k){
return (LL)k*k*k;
}
LL calc(pii x,pii y){
if ((!nn)&&(!mm))return 6LL*abs(x.fi-y.fi);
if ((!nn)||(!mm)){
if (!mm)swap(x,y);
if (x.fi<y.fi)return (LL)3*(y.se-y.fi)*(0LL+y.fi+y.se-x.fi-x.fi);
if (x.fi>y.se)return (LL)3*(y.se-y.fi)*(0LL+x.fi+x.fi-y.fi-y.se);
return (LL)3*(sqr(x.fi-y.fi)+sqr(y.se-x.fi));
}
if (x.fi>y.fi)swap(x,y);
if (x.se<y.fi)return (LL)3*(x.se-x.fi)*(y.se-y.fi)*(0LL+y.fi+y.se-x.fi-x.se);
LL s=(LL)3*(y.fi-x.fi)*(y.se-y.fi)*(y.se-x.fi);
x.fi=y.fi;
if (x.se>y.se)swap(x,y);
return s+2*cube(x.se-x.fi)+(LL)3*(x.se-x.fi)*(y.se-x.se)*(y.se-x.fi);
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d%d",&a[i].fi,&a[i].se);
for(int i=1;i<=m;i++)scanf("%d%d",&b[i].fi,&b[i].se);
sort(a+1,a+n+1),sort(b+1,b+m+1);
for(int i=1;i<=n;i++)nn+=a[i].se-a[i].fi;
for(int i=1;i<=m;i++)mm+=b[i].se-b[i].fi;
sa=sb=Sa=Sb=Data{0,0};
for(int i=1,j=1;(i<=n)||(j<=m);){
if ((i<=n)&&(j<=m))ans+=calc(a[i],b[j]);
if ((i<=n)&&((j>m)||(a[i].se<b[j].se))){
Data o=Data{(nn ? a[i].se-a[i].fi : 1),3*(sqr(a[i].se)-sqr(a[i].fi))};
i++,ans+=o-sb,sb=sb+Sb,Sa=Sa+o,Sb=0;
}
else{
Data o=Data{(mm ? b[j].se-b[j].fi : 1),3*(sqr(b[j].se)-sqr(b[j].fi))};
j++,ans+=o-sa,sa=sa+Sa,Sb=Sb+o,Sa=0;
}
}
printf("%.9f\n",ans/6.0/(nn ? nn : n)/(mm ? mm : m));
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:55:47: error: no match for ‘operator=’ (operand types are ‘Data’ and ‘int’) 55 | i++,ans+=o-sb,sb=sb+Sb,Sa=Sa+o,Sb=0; | ^ answer.code:13:8: note: candidate: ‘constexpr Data& Data::operator=(const Data&)’ 13 | struct Data{ | ^~~~ answer.code:13:8: note: no known conversion for argument 1 from ‘int’ to ‘const Data&’ answer.code:13:8: note: candidate: ‘constexpr Data& Data::operator=(Data&&)’ answer.code:13:8: note: no known conversion for argument 1 from ‘int’ to ‘Data&&’ answer.code:59:47: error: no match for ‘operator=’ (operand types are ‘Data’ and ‘int’) 59 | j++,ans+=o-sa,sa=sa+Sa,Sb=Sb+o,Sa=0; | ^ answer.code:13:8: note: candidate: ‘constexpr Data& Data::operator=(const Data&)’ 13 | struct Data{ | ^~~~ answer.code:13:8: note: no known conversion for argument 1 from ‘int’ to ‘const Data&’ answer.code:13:8: note: candidate: ‘constexpr Data& Data::operator=(Data&&)’ answer.code:13:8: note: no known conversion for argument 1 from ‘int’ to ‘Data&&’ answer.code:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ answer.code:45:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | for(int i=1;i<=n;i++)scanf("%d%d",&a[i].fi,&a[i].se); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:46:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | for(int i=1;i<=m;i++)scanf("%d%d",&b[i].fi,&b[i].se); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~