Submission #361430

# Submission time Handle Problem Language Result Execution time Memory
361430 2021-01-30T05:45:02 Z spatarel Vision Program (IOI19_vision) C++17
0 / 100
17 ms 1900 KB
#include "vision.h"

int H, W;

int index(int i, int j) {
  return i * W + j;
}

void construct_network(int H, int W, int K) {
  ::H = H;
  ::W = W;
  
  std::vector<int> diagCells[2][H + W - 1];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      diagCells[0][i + j].push_back(index(i, j));
      diagCells[1][i - j + W - 1].push_back(index(i, j));
    }
  }
  
  int diagContains[2][H + W - 1];
  std::vector<int> diagEqKANDs[2];
  int diagPrefContains[2][H + W - 1];
  int diagSuffContains[2][H + W - 1];
  int diagEqK[2];
  int diagLEqK[2];
  for (int d : {0, 1}) {
    for (int i = 0; i < W + H - 1; i++) {
      diagContains[d][i] = add_or(diagCells[d][i]);
    }
    diagPrefContains[d][0] = diagContains[d][0];
    for (int i = 1; i < W + H - 1; i++) {
      diagPrefContains[d][i] = add_or({diagPrefContains[d][i - 1], diagContains[d][i]});
    }
    diagSuffContains[d][W + H - 2] = diagContains[d][W + H - 2];
    for (int i = W + H - 3; i >= 0; i--) {
      diagSuffContains[d][i] = add_or({diagContains[d][i], diagSuffContains[d][i + 1]});
    }
    std::vector<int> tmp;
    for (int i = 0; i + K < W + H - 1; i++) {
      tmp.push_back(add_and({diagContains[d][i], diagContains[d][i + K]}));
    }
    diagEqK[d] = add_or(tmp);
    tmp.clear();
    
    if (W + H - 1 > K) {
      tmp.push_back(diagPrefContains[d][W + H - 3 - K]);
      tmp.push_back(diagSuffContains[d][K + 1]);
    }
    //printf("suff(%d)\n", K + 1);
    for (int i = 1; i + K + 1 < W + H - 1; i++) {
      //printf("pref(%d) & suff(%d)\n", i - 1, i + K + 1);
      tmp.push_back(add_or({diagPrefContains[d][i - 1], diagSuffContains[d][i + K + 1]}));
    }
    //printf("pref(%d)\n", W + H - 3 - K);
    //if (tmp.empty()) {
    //  printf("mama");
    //}
    diagLEqK[d] = add_not(add_and(tmp));
    tmp.clear();
  }
  add_or({add_and({diagEqK[0], diagLEqK[1]}),
          add_and({diagEqK[1], diagLEqK[0]})});
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 364 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 364 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 364 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 364 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Incorrect 1 ms 508 KB on inputs (0, 0), (0, 198), expected 1, but computed 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1900 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 7 ms 1132 KB Output is correct
8 Correct 7 ms 1132 KB Output is correct
9 Correct 13 ms 1900 KB Output is correct
10 Incorrect 0 ms 256 KB WA in grader: Invalid index
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 364 KB WA in grader: Invalid index
3 Halted 0 ms 0 KB -