답안 #424934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424934 2021-06-12T11:47:56 Z madlogic Vision Program (IOI19_vision) C++17
0 / 100
11 ms 1100 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

// int cur;

// int add_xor(vector<int> v) {
//   cout << "XOR" << endl;
//   for (int p : v) {
//     cout << p << ' ';
//   }
//   cout << '\n';
//   return ++cur;
// }

// int add_or(vector<int> v) {
//   cout << "OR" << endl;
//   for (int p : v) {
//     cout << p << " ";
//   }
//   cout << '\n';
//   return ++cur;
// }

// int add_and(vector<int> v) {
//   cout << "AND" << endl;
//   for (int p : v) {
//     cout << p << ' ';
//   }
//   cout << '\n';
//   return ++cur;
// }

void construct_network(int H, int W, int K) {
  if (K == 1) {
    vector<int> indsRow;
    for (int i = 0; i < H; i++) {
      vector<int> idx;
      for (int j = 0; j < W; j++) {
        idx.push_back(i * W + j);
      }
      indsRow.push_back(add_xor(idx));
    }
    vector<int> indsCol;
    for (int i = 0; i < W; i++) {
      vector<int> idx;
      for (int j = 0; j < H; j++) {
        idx.push_back(j * W + i);
      }
      indsCol.push_back(add_xor(idx));
    }
    int id1 = add_xor(indsRow);
    int id2 = add_xor(indsCol);
    int nn = (int) indsRow.size();
    vector<int> aa;
    for (int i = 0; i + 1 < nn; i++) {
      aa.push_back(add_xor({indsRow[i], indsRow[i + 1]}));
    }
    int mm = (int) indsCol.size();
    vector<int> bb;
    for (int i = 0; i + 1 < mm; i++) {
      bb.push_back(add_xor({indsCol[i], indsCol[i + 1]}));
    }
    int id3 = (aa.empty() ? -1 : add_xor(aa));
    int id4 = (bb.empty() ? -1 : add_xor(bb));
    if (id3 == -1) {
      add_xor({id1, id4});
    } else if (id4 == -1) {
      add_xor({id2, id3});
    } else {
      add_or({add_xor({id1, id4}), add_xor({id2, id3})});
    }
  } else if (1ll * H * W >= 1000) {
    vector<int> v;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (!(i == 0 && j == 0) && abs(i) + abs(j) == K) {
          v.push_back(add_and({0, i * W + j}));
        }
      }
    }
    if (!v.empty()) {
      add_or(v);
    }
  } else {
    vector<vector<vector<int>>> dp(3, vector<vector<int>>(H, vector<int>(W, -1)));
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        vector<int> v{i * W + j};
        for (int x = 0; x <= K; x++) {
          int y = K - x;
          set<int> s;
          s.insert(y);
          s.insert(-y);
          for (int ys : s) {
            int dx = i + x;
            int dy = j + ys;
            if (dx >= 0 && dx < H && dy >= 0 && dy < W) {
              int yy = dx * W + dy;
              v.push_back(yy);
            }
          }
        }
        dp[0][i][j] = add_xor(v);
        dp[1][i][j] = add_or(v);
        reverse(v.begin(), v.end());
        v.pop_back();
        if (!v.empty()) {
          dp[2][i][j] = add_xor(v);
        }
      }
    }
    vector<int> v;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int a = dp[0][i][j];
        int b = dp[1][i][j];
        if (dp[2][i][j] != -1) {
          int id1 = add_xor({a, b});
          int idx = add_and({id1, dp[2][i][j]});
          v.push_back(idx);
        }
      }
    }
    if (!v.empty()) {
      add_or(v);
    } else {
      add_and({0, 1});
    }
  }
}

// int main() {
//   ios::sync_with_stdio(false);
//   cin.tie(0);
//   construct_network(3, 3, 2);
//   return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1100 KB on inputs (0, 126), (66, 191), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -