Submission #267966

#TimeUsernameProblemLanguageResultExecution timeMemory
267966ggoorooVision Program (IOI19_vision)C++14
0 / 100
5 ms3840 KiB
#include "vision.h" #include <cstdio> #include <iostream> #include <queue> #include <set> #include <map> #define N 205 using namespace std; int h, w, k, T, en, mn = 2e9, mx, v[N][N], z1[40005], z2[40005]; int dr[4] = {-1, 0, 0, 1}, dc[4] = {0, -1, 1, 0}; set<int> vi[40005]; vector<int> ans, l1[405], l2[405]; queue<int> qr, qc, qe; int pq_num(int p, int q) { return p * w + q; } void pu(int p, int q, int e) { if (p < 0 || p >= h || q < 0 || q >= w || v[p][q] == T) return; v[p][q] = T; qr.push(p); qc.push(q); qe.push(e); } vector<int> in; void f(int p, int q, int k) { int i, tr, tc, te, re, x1, x2, t1, t2; x1 = pq_num(p, q); pu(p, q, 0); in.clear(); while (!qr.empty()) { tr = qr.front(); qr.pop(); tc = qc.front(); qc.pop(); te = qe.front(); qe.pop(); if (te == k) { x2 = pq_num(tr, tc); if (vi[x1].count(x2) == 1) continue; vi[x1].insert(x2); vi[x2].insert(x1); in.push_back(x2); // in.push_back(x1); // in.push_back(x2); // re = add_and(in); // mn = min(mn, re); // mx = max(mx, re); } else { for (i = 0; i < 4; i++) { pu(tr + dr[i], tc + dc[i], te + 1); } } } if (!in.empty()) { t1 = add_or(in); t2 = add_and({t1, x1}); ans.push_back(t2); } } //int g(int p, int q, int z) { // int re = 0; // re = 0; // if (p - k >= 0) re = (re | z1[p - k]); // if (p + k <= h + w - 2) re = (re | z1[p + k]); // if (q - k >= 0) re = (re | z2[q - k]); // if (q + k <= h + w - 2) re = (re | z2[q + k]); // return re; //} void construct_network(int hh, int ww, int kk) { int i, j, t1, t2, x1, x2; h = hh; w = ww; k = kk; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { l1[i + j].push_back(pq_num(i, j)); l2[j - i + h - 1].push_back(pq_num(i, j)); } } for (i = 0; i < h + w - 1; i++) { z1[i] = add_or(l1[i]); z2[i] = add_or(l2[i]); } ans.clear(); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { t1 = i + j; t2 = j - i + h - 1; in.clear(); k = kk; if (t1 - k >= 0) in.push_back(z1[t1 - k]); if (t1 + k <= h + w - 2) in.push_back(z1[t1 + k]); if (t2 - k >= 0) in.push_back(z2[t2 - k]); if (t2 + k <= h + w - 2) in.push_back(z2[t2 + k]); if (!in.empty()) x1 = add_or(in); else x1 = -1; if (x1 == -1) continue; in.clear(); k = kk + 1; if (t1 - k >= 0) in.push_back(z1[t1 - k]); if (t1 + k <= h + w - 2) in.push_back(z1[t1 + k]); if (t2 - k >= 0) in.push_back(z2[t2 - k]); if (t2 + k <= h + w - 2) in.push_back(z2[t2 + k]); if (!in.empty()) x2 = add_or(in); else x2 = -1; if (x2 == -1) ans.push_back(add_and({x1, pq_num(i, j)})); else ans.push_back(add_and({add_xor({x1, x2}), pq_num(i, j)})); } } add_or(ans); }

Compilation message (stderr)

vision.cpp: In function 'void f(int, int, int)':
vision.cpp:29:21: warning: unused variable 're' [-Wunused-variable]
   29 |  int i, tr, tc, te, re, x1, x2, t1, t2;
      |                     ^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...