답안 #289859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289859 2020-09-03T07:06:48 Z arman_ferdous Vision Program (IOI19_vision) C++17
12 / 100
30 ms 2944 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

using vi = vector<int>;
const int N = 401;

int H, W, K;

vi getdia1(int r, int c) {
  vi cells;
  for(;;) {
    cells.push_back(r * W + c);
    r--, c++;
    if(r < 0 || c >= W) break;
  }
  return cells;
}

vi getdia2(int r, int c) {
  vi cells;
  for(;;) {
    cells.push_back(r * W + c);
    r--, c--;
    if(r < 0 || c < 0) break;
  }
  return cells;
}

int dia1[N + N], dia2[N + N];
int prefix1[N + N], prefix2[N + N];

void construct_network(int h, int w, int k) {
  H = h, W = w, K = k;

  for(int i = 0; i < h; i++) {
    vi cells = getdia1(i, 0);
    dia1[i] = add_xor(cells);
  }
  for(int j = 1; j < w; j++) {
    vi cells = getdia1(h - 1, j);
    dia1[h - 1 + j] = add_xor(cells);
  }
  for(int i = 0; i < h + w - 1; i++) {
    vi tmp;
    for(int j = 0; j <= i; j++) tmp.push_back(dia1[j]);
    prefix1[i] = add_xor(tmp);
  }
  vi KKdifres, Kdifres;
  for(int i = 0; i + K < h + w - 1; i++) {
    vi tmp(2); 
    tmp[0] = prefix1[i];
    tmp[1] = prefix1[i + K];
    KKdifres.push_back(add_and(tmp));
  }
  for(int i = 0; i + K - 1 < h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix1[i];
    tmp[1] = prefix1[i + K - 1];
    Kdifres.push_back(add_and(tmp));
  }
  int greaterthanK, greaterthanKK;
  greaterthanK = add_or(Kdifres);
  greaterthanKK = add_or(KKdifres);

  vi tt(2); 
  tt[0] = greaterthanK;
  tt[1] = greaterthanKK;
  int result1 = add_xor(tt);

  for(int i = 0; i < h; i++) {
    vi cells = getdia2(i, w - 1);
    dia2[i - w + 1 + w] = add_xor(cells); 
  }
  for(int j = w - 2; j >= 0; j--) {
    vi cells = getdia2(h - 1, j);
    dia2[h - 1 - j + w] = add_xor(cells);
  }
  for(int i = 1; i <= h - 1 + w; i++) {
    vi tmp;
    for(int j = 1; j <= i; j++) tmp.push_back(dia2[j]);
    prefix2[i] = add_xor(tmp);
  }
  KKdifres.clear(); Kdifres.clear();
  for(int i = 1; i + K <= h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix2[i];
    tmp[1] = prefix2[i + K];
    KKdifres.push_back(add_and(tmp));
  }
  for(int i = 1; i + K - 1 <= h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix2[i];
    tmp[1] = prefix2[i + K - 1];
    Kdifres.push_back(add_and(tmp));
  }
  greaterthanK = add_or(Kdifres);
  greaterthanKK = add_or(KKdifres);

  tt[0] = greaterthanK;
  tt[1] = greaterthanKK;
  int result2 = add_xor(tt);

  tt[0] = result1;
  tt[1] = result2;
  add_or(tt);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 1 ms 384 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 1 ms 384 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 1 ms 384 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 1 ms 384 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 6 ms 824 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 6 ms 768 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 6 ms 768 KB Output is correct
11 Correct 6 ms 768 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 6 ms 768 KB Output is correct
16 Correct 6 ms 768 KB Output is correct
17 Correct 6 ms 768 KB Output is correct
18 Correct 6 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 4 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 7 ms 768 KB Output is correct
11 Correct 6 ms 768 KB Output is correct
12 Correct 6 ms 748 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 7 ms 768 KB Output is correct
15 Correct 6 ms 764 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 7 ms 896 KB Output is correct
18 Correct 6 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 17 ms 1920 KB Output is correct
21 Incorrect 16 ms 1792 KB on inputs (0, 0), (199, 99), expected 0, but computed 1
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 2944 KB on inputs (126, 120), (176, 169), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 1 ms 384 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -