Submission #555017

# Submission time Handle Problem Language Result Execution time Memory
555017 2022-04-30T00:30:54 Z slime Vision Program (IOI19_vision) C++14
12 / 100
13 ms 1680 KB
#include <bits/stdc++.h>
#include "vision.h"

#include <map>

void construct_network(int H, int W, int K) {
	std::vector<int> Ns;
  std::vector<int> by_sum, by_diff;
  std::map<int, std::vector<int> > mp_sum, mp_diff;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      mp_sum[i + j].push_back(i*W + j);
      mp_diff[i - j].push_back(i*W + j);
    }
  }
  std::vector<int> analyze; // Necessary conditions, i.e. AND clause
  for(auto x: mp_sum) {
    by_sum.push_back(add_or(x.second));
  }
  for(auto x: mp_diff) {
    by_diff.push_back(add_or(x.second));
  }
  // Condition 1: at least one of these two arrays' 1s are exactly K cells apart
  std::vector<int> cond1;
  for(int i=0; i<by_sum.size(); i++) {
    if(i + K < by_sum.size()) {
      std::vector<int> uwu = {by_sum[i], by_sum[i + K]};
      cond1.push_back(add_and(uwu));
    }
  }
  for(int i=0; i<by_diff.size(); i++) {
    if(i + K < by_diff.size()) {
      std::vector<int> uwu = {by_diff[i], by_diff[i + K]};
      cond1.push_back(add_and(uwu));
    }
  }
  
  // Only one in cond1 array = 1 is necessary (but at least 1)!
  analyze.push_back(add_or(cond1));
  /*
  // condition 2: [1 + K 0s] should not appear in any of them
  std::vector<int> cond2;
  for(int i=0; i<by_sum.size(); i++) {
    if(i + 1 + K < by_sum.size()) {
      std::vector<int> patt; // does this subarray match the pattern?
      std::vector<int> uwu = {by_sum[i]};
      patt.push_back(add_and(uwu));
      uwu.clear();
      for(int j=i+1; j<i+1+K; j++) uwu.push_back(by_sum[j]);
      patt.push_back(add_not(add_or(uwu)));
      // Everything in patt = 1 iff by_sum[i] = 1 and all by_sum[i+1] to by_sum[i+K] = 0
      cond2.push_back(add_and(patt)); // = 1 if match pattern, = 0 otherwise
    }
  }
  //analyze.push_back(add_not(add_or(cond2))); // = 1 if all cond2 = 0, i.e. no pattern found
  */
  add_and(analyze); // answer

}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int i=0; i<by_sum.size(); i++) {
      |                ~^~~~~~~~~~~~~~
vision.cpp:26:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     if(i + K < by_sum.size()) {
      |        ~~~~~~^~~~~~~~~~~~~~~
vision.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i=0; i<by_diff.size(); i++) {
      |                ~^~~~~~~~~~~~~~~
vision.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     if(i + K < by_diff.size()) {
      |        ~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 396 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 304 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 3 ms 552 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 7 ms 980 KB Output is correct
21 Incorrect 6 ms 980 KB on inputs (0, 0), (199, 99), expected 0, but computed 1
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1680 KB on inputs (126, 120), (176, 169), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -