Submission #388526

#TimeUsernameProblemLanguageResultExecution timeMemory
388526JimmyZJXVision Program (IOI19_vision)C++14
100 / 100
38 ms3352 KiB
#include <iostream> #include <fstream> #include <algorithm> #include <cstring> #include <climits> #include <cassert> #include <tuple> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #include <string> using namespace std; typedef long long LL; typedef vector<int> Vi; typedef vector<bool> Vb; typedef vector<vector<int>> Vii; #define forR(i, n) for (int i = 0; i < (n); i++) int add_not(int N); void Get_le_k(Vi& rs, Vi& d1r, int K, int& dd1_le_k); int add_and(Vi Ns); int add_or(Vi Ns); int add_xor(Vi Ns); int Get_le_k(const Vi& dr, int K) { Vi rs; for (int i = 0; i < dr.size() - K; i++) { Vi range; // [i, i+K] for (int j = 0; j <= K; j++) { range.push_back(dr[i + j]); } int or_range = add_or(range); int xor_range = add_xor(range); rs.push_back(add_and(Vi{ or_range, add_not(xor_range) })); } int dd_ge1_leK = add_or(rs); int dd_eq0 = add_not(add_or(dr)); return add_or(Vi{ dd_eq0, dd_ge1_leK }); } void construct_network(int H, int W, int K) { // d1[i] x+y == i d2[i] x+(W-1-y) == i Vii d1(H + W - 1), d2(H + W - 1); forR(x, H) forR(y, W) { int index = x * W + y; int i1 = x + y, i2 = x + (W - 1 - y); d1[i1].push_back(index); d2[i2].push_back(index); } Vi d1r, d2r; for (auto& d1_line : d1) { d1r.push_back(add_xor(d1_line)); } for (auto& d2_line : d2) { d2r.push_back(add_xor(d2_line)); } int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k; // d1 { Vi rs; for (int i = 0; i < d1r.size() - K; i++) { rs.push_back(add_and(Vi{ d1r[i], d1r[i + K] })); } dd1_eq_k = add_or(rs); dd1_le_k = Get_le_k(d1r, K); } // d2 { Vi rs; for (int i = 0; i < d2r.size() - K; i++) { rs.push_back(add_and(Vi{ d2r[i], d2r[i + K] })); } dd2_eq_k = add_or(rs); dd2_le_k = Get_le_k(d2r, K); } int dd1_k = add_and(Vi{ dd1_eq_k, dd2_le_k }); int dd2_k = add_and(Vi{ dd2_eq_k, dd1_le_k }); add_or(Vi{ dd1_k, dd2_k }); return; } #ifdef TEST_LOCAL int add_not(int N) { return -1; } int add_and(Vi Ns) { return -1; } int add_or(Vi Ns) { return -1; } int add_xor(Vi Ns) { return -1; } int main() { construct_network(200, 200, 1); return 0; } #endif

Compilation message (stderr)

vision.cpp: In function 'int Get_le_k(const Vi&, int)':
vision.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < dr.size() - K; i++) {
      |                  ~~^~~~~~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:73:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   for (int i = 0; i < d1r.size() - K; i++) {
      |                   ~~^~~~~~~~~~~~~~~~
vision.cpp:84:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   for (int i = 0; i < d2r.size() - K; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...