QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216241 | #7583. Faraway | SolitaryDream# | AC ✓ | 20ms | 3520kb | C++17 | 1.6kb | 2023-10-15 16:54:03 | 2023-10-15 16:54:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=111;
int T,n,m;
int x[N],y[N],k[N],t[N];
int calc(int L,int R,int u)
{
int ret=R/60+(R%60>=u);
if(L>=1)
ret-=((L-1)/60+((L-1)%60>=u));
return ret;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--)
{
cin>>n>>m;
vector<int> X,Y;
X.push_back(0);
X.push_back(m+1);
Y.push_back(0);
Y.push_back(m+1);
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i]>>k[i]>>t[i],X.push_back(x[i]),Y.push_back(y[i]);
sort(X.begin(),X.end());
sort(Y.begin(),Y.end());
X.erase(unique(X.begin(),X.end()),X.end());
Y.erase(unique(Y.begin(),Y.end()),Y.end());
int ans=0;
for(int i=0;i+1<X.size();i++)
for(int j=0;j+1<Y.size();j++)
{
int lx=X[i],rx=X[i+1]-1;
int ly=Y[j],ry=Y[j+1]-1;
for(int u=0;u<60;u++)
for(int v=0;v<60;v++)
{
bool ok=1;
for(int i=1;i<=n;i++)
if((abs(lx+u-x[i])+abs(ly+v-y[i]))%k[i]!=t[i])
{
ok=0;
break;
}
if(!ok)
continue;
ans+=calc(0,rx-lx,u)*calc(0,ry-ly,v);
}
}
cout<<ans<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
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: 20ms
memory: 3520kb
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