# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
898537 | jamjanek | Garden (JOI23_garden) | C++17 | 3020 ms | 98640 KiB |
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;
int wiersz[10010];
int kolumna[10010];
bool tab[10010][10010];
int wys[10010];
int main()
{
int n, m, d, i, j, x, y;
scanf("%d%d%d", &n, &m, &d);
for(i=0;i<n;i++){
scanf("%d%d", &x, &y);
swap(x,y);
x = d-x-1;
wiersz[x] = 1;
kolumna[y] = 1;
wiersz[x+d] = 1;
kolumna[y+d] = 1;
}
for(i=0;i<m;i++){
scanf("%d%d", &x, &y);
swap(x,y);
x = d-x-1;
tab[x][y] = 1;
tab[x+d][y] = 1;
tab[x][y+d] = 1;
tab[x+d][y+d] = 1;
}
for(i=0;i<2*d;i++)
if(wiersz[i])
for(j=0;j<2*d;j++)
tab[i][j] = 1;
for(i=0;i<2*d;i++)
if(kolumna[i])
for(j=0;j<2*d;j++)
tab[j][i] = 1;
int wynik = d*d;
if(d<3)while(true);
//for(i=0;i<2*d;i++){for(j=0;j<2*d;j++)printf("%d", (int)tab[i][j]);printf("\n");}
for(i=0;i<2*d;i++){
vector<pair<int,int>>KM;
KM.push_back({-1,-1});
for(j=0;j<2*d;j++){
if(tab[i][j]==1)
wys[j] = 0;
else
wys[j]++;
while(KM.back().first>=wys[j])KM.pop_back();
//printf("%d %d: %d %d\n", i, j, wys[j], (j-KM.back().second));
if(wys[j]>0)
wynik = min(wynik,(d-wys[j])*(d-(j-KM.back().second)));
KM.push_back({wys[j], j});
}
}
printf("%d\n", wynik);
return 0;
}
Compilation message (stderr)
# | 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... |