QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#191097 | #7520. Monster Generator | ucup-team055# | WA | 1ms | 3464kb | C++17 | 2.8kb | 2023-09-29 17:50:21 | 2023-11-04 18:35:59 |
Judging History
你现在查看的是最新测评结果
- [2023-11-04 16:34:13]
- hack成功,自动添加数据
- (//qoj.ac/hack/422)
- [2023-11-04 16:28:16]
- hack成功,自动添加数据
- (//qoj.ac/hack/420)
- [2023-09-29 17:50:21]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(p) p.begin(),p.end()
using ll =long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
void solve(){
ll N,M;
cin>>N>>M;
vector<ll> A(N),B(N),C(N),D(N);
rep(i,0,N) cin>>A[i]>>B[i]>>C[i]>>D[i];
set<ll> s;
rep(i,0,N){
if(B[i]==D[i]) continue;
ll X=A[i]-C[i],Y=D[i]-B[i];
if(Y<0) X*=-1,Y*=-1;
if(X<0||Y==0) continue;
s.insert((X+Y-1)/Y);
}
rep(rp,0,2){
swap(A,C),swap(B,D);
rep(i,0,N) rep(j,i+1,N){
ll X=A[i]-A[j],Y=B[i]-B[j];
if(Y<0) X*=-1,Y*=-1;
if(X<0||Y==0) continue;
s.insert((X+Y-1)/Y);
}
}
s.insert(M+1);
s.insert(0);
using l8=__int128;
l8 ans=0;
while(true){
ll L=(*s.begin());
s.erase(L);
if(L==M+1) break;
ll R=(*s.begin());
vector<int> order(N);
rep(i,0,N) order[i]=i;
vector<l8> S(N),T(N);
rep(i,0,N){
S[i]=(l8)(A[i])*(l8)(2)+(l8)(B[i])*(l8)(L+R-1);
T[i]=(l8)(C[i])*(l8)(2)+(l8)(D[i])*(l8)(L+R-1);
}
sort(all(order),[&](int l,int r){
if((-S[l]+T[l]>=0)^(-S[r]+T[r]>=0)){
return (-S[l]+T[l]>=0);
}
if(-S[l]+T[l]>=0){
return S[l]<S[r];
}
return T[l]>T[r];
});
vector<l8> X(N),Y(N);
rep(i,0,N){
int a=order[i];
X[i]-=A[a];
Y[i]-=B[a];
if(i!=N-1){
X[i+1]=X[i]+C[a];
Y[i+1]=Y[i]+D[a];
}
}
rep(i,0,N){
l8 l=L,r=R;
rep(j,0,N){
if(i==j) continue;
l8 tmp1=X[j]-X[i],tmp2=Y[i]-Y[j];
if(tmp2==0){
if(tmp1==0&&j<i) r=-1;
if(tmp1<0) r=-1;
}
else if(tmp2>0){
if(tmp1<=0) r=-1;
else{
r=min(r,(tmp1-(l8)(j<i))/tmp2+1);
}
}
else{
tmp1*=-1,tmp2*=-1;
if(tmp1>0||(tmp1==0&&j<i)){
l=max(l,(tmp1-(l8)(j>i))/tmp2+1);
}
}
}
if(l<r){
ans-=(((r-l)*(r-1+l))/2)*Y[i]+X[i]*(r-l);
}
}
}
unsigned long long out=0;
rep(i,0,64){
if(ans&((l8)(1)<<i)) out+=(1ULL<<i);
}
cout<<out<<"\n";
}
/*
*
3 5
3 1 5 2
4 2 1 3
1 9 100 1
*
*/
int main(){
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3420kb
input:
3 5 3 1 5 2 4 2 1 3 1 9 100 1
output:
113
result:
ok single line: '113'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
3 100000000 3 1 5 2 4 2 1 3 1 9 100 1
output:
35000000549999998
result:
ok single line: '35000000549999998'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3420kb
input:
10 1000000000000000000 776874380544333 197 471391764744275 33 159838820333814 107 677112662750393 41 962335658276824 48 255593531071176 11 127404116579775 209 268525254990127 34 647620110614714 76 897947476313307 13 146196843402516 221 772928712898807 39 637929916804442 2 716937021892338 15 64200226...
output:
13019975980102931693
result:
wrong answer 1st lines differ - expected: '17883317185357051350', found: '13019975980102931693'