Submission #259507

# Submission time Handle Problem Language Result Execution time Memory
259507 2020-08-07T23:51:25 Z anayk Vision Program (IOI19_vision) C++14
21 / 100
11 ms 1152 KB
#include "vision.h"

void construct_network(int H, int W, int K) {
  std::vector<int> row(H, 0), col(W, 0);

  for(int i = 0; i < H; i++) {
    std::vector<int> cur;
    for(int j = 0; j < W; j++) {
      cur.push_back(i*W + j);
    }
    row[i] = add_or(cur);
  }

  for(int i = 0; i < W; i++) {
    std::vector<int> cur;
    for(int j = 0; j < H; j++) {
      cur.push_back(j*W + i);
    }
    col[i] = add_or(cur);
  }

  std::vector<int> spec = {5, 7, 8};

  std::vector<int> rows[spec.size()], cols[spec.size()];
  for(int i = 0; i < spec.size(); i++) {
    for(int j = 0; j < spec[i]; j++) {
      std::vector<int> cur;
      rows[i].push_back(-1);
      for(int k = j; k < H; k += spec[i])
        cur.push_back(row[k]);
      if(cur.size() == 0)
        continue;
      rows[i][j] = add_or(cur);
    }
  }

  for(int i = 0; i < spec.size(); i++) {
    for(int j = 0; j < spec[i]; j++) {
      std::vector<int> cur;
      cols[i].push_back(-1);
      for(int k = j; k < W; k += spec[i])
        cur.push_back(col[k]);
      if(cur.size() == 0)
        continue;
      cols[i][j] = add_or(cur);
    }
  }

  std::vector<int> mrows[spec.size()], mcols[spec.size()];
  for(int i = 0; i < spec.size(); i++) {
    std::vector<int> cur;
    for(int j = 0; j < spec[i]; j++)
      if(rows[i][j] > -1) cur.push_back(rows[i][j]);
    if(cur.size() != 0)
      mrows[i].push_back(add_xor(cur));

    for(int j = 1; j < spec[i]; j++) {
      std::vector<int> temp;
      for(int k = 0; k < spec[i]; k++) {
        if(rows[i][(k+j)%spec[i]] > -1 && rows[i][k] > -1) temp.push_back(add_and({rows[i][k], rows[i][(k+j)%spec[i]]}));
      }
      mrows[i].push_back(-1);
      if(temp.size() == 0)
        continue;
      mrows[i][j] = add_or(temp);
    }
  }

  for(int i = 0; i < spec.size(); i++) {
    std::vector<int> cur;
    for(int j = 0; j < spec[i]; j++)
      if(cols[i][j] > -1) cur.push_back(cols[i][j]);
    if(cur.size() != 0)
      mcols[i].push_back(add_xor(cur));

    for(int j = 1; j < spec[i]; j++) {
      std::vector<int> temp;
      for(int k = 0; k < spec[i]; k++) {
        if(cols[i][(k+j)%spec[i]] > -1 && cols[i][k] > -1) temp.push_back(add_and({cols[i][k], cols[i][(k+j)%spec[i]]}));
      }
      mcols[i].push_back(-1);
      if(temp.size() == 0)
        continue;
      mcols[i][j] = add_or(temp);
    }
  }

  std::vector<int> finale;
  for(int i = 0; i <= K; i++) {
    std::vector<int> temp;
    if(i == H)
      break;
    if(K-i >= W)
      continue;
    for(int j = 0; j < spec.size(); j++) {
      if(mrows[j][i%spec[j]] == -1 || mcols[j][(K-i)%spec[j]] == -1) continue;
      temp.push_back(mrows[j][i%spec[j]]);
      temp.push_back(mcols[j][(K-i)%spec[j]]);
    }

    finale.push_back(add_and(temp));
  }
  int ans = add_or(finale);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++) {
                  ~~^~~~~~~~~~~~~
vision.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++) {
                  ~~^~~~~~~~~~~~~
vision.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++) {
                  ~~^~~~~~~~~~~~~
vision.cpp:69:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++) {
                  ~~^~~~~~~~~~~~~
vision.cpp:95:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0; j < spec.size(); j++) {
                    ~~^~~~~~~~~~~~~
vision.cpp:103:7: warning: unused variable 'ans' [-Wunused-variable]
   int ans = add_or(finale);
       ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Incorrect 1 ms 256 KB on inputs (0, 0), (27, 0), expected 0, but computed 1
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Incorrect 1 ms 256 KB on inputs (0, 0), (27, 0), expected 0, but computed 1
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB on inputs (0, 0), (0, 41), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Incorrect 2 ms 512 KB on inputs (0, 0), (43, 134), expected 0, but computed 1
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1152 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 0), (0, 41), expected 0, but computed 1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Incorrect 1 ms 256 KB on inputs (0, 0), (27, 0), expected 0, but computed 1
31 Halted 0 ms 0 KB -