QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219854 | #7583. Faraway | PhantomThreshold# | AC ✓ | 21ms | 3440kb | C++20 | 1.5kb | 2023-10-19 19:10:41 | 2023-10-19 19:10:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=60;
ll gao(ll L,ll R,ll a){
L-=a;
R-=a;
ll restR=R%mod;
if (restR<0) restR+=mod;
ll restL=L%mod;
if (restL>0) restL-=mod;
L-=restL;
R-=restR;
return (R-L)/mod+1;
}
ll n,m;
ll x[20],y[20],k[20],t[20];
void solve(){
cin >> n >> m;
for (int i=1;i<=n;i++) cin >> x[i] >> y[i] >> k[i] >> t[i];
vector<ll> vx,vy;
for (int i=1;i<=n;i++){
vx.push_back(x[i]);
vy.push_back(y[i]);
}
vx.push_back(0);vx.push_back(m+1);
vy.push_back(0);vy.push_back(m+1);
sort(vx.begin(),vx.end());
sort(vy.begin(),vy.end());
int szx=vx.size();
int szy=vy.size();
ll ans=0;
for (int selx=1;selx<szx;selx++){
ll lx=vx[selx-1];
ll rx=vx[selx]-1;
if (lx>rx) continue;
for (int sely=1;sely<szy;sely++){
ll ly=vy[sely-1];
ll ry=vy[sely]-1;
if (ly>ry) continue;
for (ll a=0;a<mod;a++){
for (ll b=0;b<mod;b++){
bool flag=1;
for (int i=1;i<=n;i++){
ll tmp=0;
if (lx>=x[i]) tmp+=a-x[i];
else tmp+=x[i]-a;
if (ly>=y[i]) tmp+=b-y[i];
else tmp+=y[i]-b;
tmp=tmp%k[i];
if (tmp<0) tmp+=k[i];
if (tmp!=t[i]){
flag=0;
break;
}
}
if (!flag) continue;
ans+=gao(lx,rx,a)*gao(ly,ry,b);
}
}
}
}
cout << ans << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
int Tcase=10;
cin >> Tcase;
for (;Tcase--;){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
2 2 5 1 2 4 2 3 1 2 1 2 5 1 2 4 2 1 2 4 3
output:
10 0
result:
ok 2 number(s): "10 0"
Test #2:
score: 0
Accepted
time: 21ms
memory: 3424kb
input:
10 10 950006 879210 618398 2 0 413993 805537 5 0 614389 782151 5 4 616385 454674 4 2 6020 332147 5 0 77932 43110 4 1 143614 196643 4 0 937161 934707 4 1 318567 789911 4 0 194658 555381 5 3 10 967857178 8983267 44864625 3 2 141087113 359274718 2 1 909006720 262061158 3 0 840340929 715591525 3 2 76531...
output:
0 0 0 116256265 43298776834 1839945977784 820599567890959 19922821864719464 50544306663055 64150016306836
result:
ok 10 numbers