(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1065731

#TimeUsernameProblemLanguageResultExecution timeMemory
1065731not_amirGarden (JOI23_garden)C++14
45 / 100
3096 ms27208 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define F(x) ((x)<=0)?((x)+d):(x) int main(){ ios_base::sync_with_stdio(false), cin.tie(NULL); int n, m, d; cin >> n >> m >> d; vector<pii> pq(n), rs(m); vector<bool> req_x(d), req_y(d); vector<int> prv_s(d, -1); vector<vector<bool> > grid(d, vector<bool>(d)); for(int i = 0; i < n; i++){ int p, q; cin >> p >> q; req_x[p] = 1; req_y[q] = 1; pq[i] = {p, q}; } for(int i = 0; i < m; i++){ int r, s; cin >> r >> s; grid[r][s] = 1; prv_s[s] = r; rs[i] = {r, s}; } int ans = d*d; vector<vector<int> > rx_s(2*d); for(int lx = 0; lx < d; lx++){ for(int y = 0; y < d; y++){ if(grid[(lx + d - 1) % d][y]) prv_s[y] = lx + d - 1; } for(int y = 0; y < d; y++) if(prv_s[y] != -1) rx_s[prv_s[y]].push_back(y); vector<int> ry(d), prv_y(d, -1), nxt_y(d, -1); for(int i = 0; i < d; i++) ry[i] += req_y[i]; int maxdiff = 0, rx = lx + d; while(rx > lx){ if(req_x[(rx-1) % d]) break; rx--; for(int y : rx_s[rx]) ry[y]++; } vector<int> ry_w; for(int y = 0; y < d; y++) if(ry[y]) ry_w.push_back(y); for(int i = 0; i < ry_w.size(); i++){ int a = ry_w[i]; int b = ry_w[(i+1) % ry_w.size()]; prv_y[b] = a; nxt_y[a] = b; } for(int y : ry_w) maxdiff = max(maxdiff, F(nxt_y[y] - y)); for(;rx < lx + d;rx++){ ans = min(ans, (d - (maxdiff-1)) * (rx - lx)); for(int y : rx_s[rx]) if(--ry[y] == 0){ maxdiff = max(maxdiff, F(nxt_y[y] - prv_y[y])); prv_y[nxt_y[y]] = prv_y[y]; nxt_y[prv_y[y]] = nxt_y[y]; } } ans = min(ans, (d - (maxdiff-1)) * (rx - lx)); } cout << ans << '\n'; }

Compilation message (stderr)

garden.cpp: In function 'int main()':
garden.cpp:39:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |         for(int i = 0; i < d; i++)
      |         ^~~
garden.cpp:41:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   41 |       int maxdiff = 0, rx = lx + d;
      |       ^~~
garden.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int i = 0; i < ry_w.size(); i++){
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...