This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n,m,d;
cin>>n>>m>>d;
vector<int>p(n),q(n),r(m),s(m);
vector<int>cx(d,0),cy(d,0);
for(int i=0;i<n;i++){
cin>>p[i]>>q[i];
cx[p[i]]++;
cy[q[i]]++;
}
for(int i=0;i<m;i++){
cin>>r[i]>>s[i];
}
int ans=d*d;
for(int i=0;i<(1<<m);i++){
for(int j=0;j<m;j++){
if(i&(1<<j)){
cx[r[j]]++;
}
else{
cy[s[j]]++;
}
}
int X=0,curx=0;
for(int j=0;j<2*d;j++){
if(cx[j%d]==0){
curx++;
}
else{
curx=0;
}
X=max(X,curx);
}
int Y=0,cury=0;
for(int j=0;j<2*d;j++){
if(cy[j%d]==0){
cury++;
}
else{
cury=0;
}
Y=max(Y,cury);
}
ans=min(ans,(d-X)*(d-Y));
for(int j=0;j<m;j++){
if(i&(1<<j)){
cx[r[j]]--;
}
else{
cy[s[j]]--;
}
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |