답안 #286788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286788 2020-08-30T22:43:21 Z medmdg Vision Program (IOI19_vision) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "vision.h"
using namespace std;

void construct_network(int H, int W, int K){
    int b1=-1,b2;
    for(int i=0;i<H*W;i+=20){
        vector<int> h;
        for(int j=i;j<min(i+20,H*W);j++){
            h.push_back(j);
        }
        if(add_or[h]){
            for(int j=i;j<H*W;j++){
                if(add_not[j]==0){
                    if(b1==-1){
                        b1=j;
                    }else{
                        b2=j;
                    }
                }
            }
        }
        int x1=b1%W;
        int x2=b2%W;
        int y1=b1/W;
        int y2=b2/W;
        bool tr=false;
        if(abs(x1-x2)+abs(y1-y2)==K){
            tr=true;
        }
        vector<int> h;
        h.push_back(b1);
        if(tr){
            int f=add_or[h];
        }else{
            int f=add_not[b1];
        }
    }
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:12:18: error: no match for 'operator[]' (operand types are 'int(std::vector<int>)' and 'std::vector<int>')
   12 |         if(add_or[h]){
      |                  ^
vision.cpp:14:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |                 if(add_not[j]==0){
      |                             ^
vision.cpp:31:21: error: redeclaration of 'std::vector<int> h'
   31 |         vector<int> h;
      |                     ^
vision.cpp:8:21: note: 'std::vector<int> h' previously declared here
    8 |         vector<int> h;
      |                     ^
vision.cpp:34:25: error: no match for 'operator[]' (operand types are 'int(std::vector<int>)' and 'std::vector<int>')
   34 |             int f=add_or[h];
      |                         ^
vision.cpp:34:17: warning: unused variable 'f' [-Wunused-variable]
   34 |             int f=add_or[h];
      |                 ^
vision.cpp:36:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   36 |             int f=add_not[b1];
      |                             ^
vision.cpp:36:29: error: invalid conversion from 'int (*)(int)' to 'int' [-fpermissive]
vision.cpp:36:17: warning: unused variable 'f' [-Wunused-variable]
   36 |             int f=add_not[b1];
      |                 ^