Submission #1048696

#TimeUsernameProblemLanguageResultExecution timeMemory
1048696MercubytheFirstVision Program (IOI19_vision)C++17
44 / 100
26 ms2876 KiB
#include "bits/stdc++.h" #include "vision.h" #define pb push_back #define endl '\n' #define fi first #define se second #define CDIV(a,b) (((a)+(b)-(1))/(b)) using ll = long long; using ld = long double; const ll inf = 1e17 + 37; const ll mod = 1e9 + 7; const ll N = 3000 + 1; const ld eps = 1e-9; const ld PI = acos((ld)-1); template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a); template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v); template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p); template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s); template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s); using namespace std; void construct_network(int H, int W, int K) { std::vector<int> Ns; auto dist = [&] (int p1, int p2) -> int { int x = p1 / W, y = p1 % W; int xx = p2 / W, yy = p2 % W; // cout << x << ' ' << y << " : " << xx << ' ' << yy << ' ' << abs(x - xx) + abs(y - yy) << endl; return abs(x - xx) + abs(y - yy); }; int last = H * W; vector<vector<int> > pairs(H*W); for(int i = 0; i < H*W; ++i) { for(int j = 0; j <= i; ++j) { if(dist(i, j) == K) { pairs[i].push_back(j); } } if(!pairs[i].empty()) { add_or(pairs[i]); add_and({last, i}); last++; Ns.push_back(last); last++; } } assert(!Ns.empty()); add_or(Ns); } template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) { os << "["; for(size_t i = 0; i + 1 < N; ++i) { os << a[i] << ", "; } if(N > 0) os << a[N - 1]; os << "]"; return os; } template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { os << "(" << p.first << ", " << p.second << ") "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { os << '['; for(auto x : v) os << x << ", "; os << "] "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } // template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; }
#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...