답안 #856397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856397 2023-10-03T11:48:30 Z Trisanu_Das Vision Program (IOI19_vision) C++17
컴파일 오류
0 ms 0 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std; 
void construct_network(int h, int w, int k){
  vector<int> ans;
  if(k == 1){
    vector<int> r(h), c(w);
    for(int i = 0; i < h; i++){
      vector<int> res;
      for(j = 0; j < w; j++) res.push_back(i * w + j);
      r[i] = res;
    }
    for(int i = 0; i < w; i++){
      vector<int> res;
      for(j = 0; j < h; j++) res.push_back(i * h + j);
      r[i] = res;
    }
    int xr = add_xor(r), xc = add_xor(c);
    for(int i = 0; i < h; i++) ans.push_back(add_and({r[i - 1], r[i], xr}));
    for(int i = 0; i < w; i++) ans.push_back(add_and({c[i - 1], c[i], xc}));
  }else{
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        vector<int> res;
        for(int x = 0; x < h; x++) for(int y = 0; y < w; y++) if(abs(i - x) + abs(j - y) == k) res.push_back(x * w + y);
        if(!res.empty()) ans.push_back(add_and({add_or(res), i * w + j}));
      }
    }
  }
  add_or(ans);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:10:11: error: 'j' was not declared in this scope
   10 |       for(j = 0; j < w; j++) res.push_back(i * w + j);
      |           ^
vision.cpp:11:14: error: cannot convert 'std::vector<int>' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   11 |       r[i] = res;
      |              ^~~
      |              |
      |              std::vector<int>
vision.cpp:15:11: error: 'j' was not declared in this scope
   15 |       for(j = 0; j < h; j++) res.push_back(i * h + j);
      |           ^
vision.cpp:16:14: error: cannot convert 'std::vector<int>' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   16 |       r[i] = res;
      |              ^~~
      |              |
      |              std::vector<int>