Submission #152046

# Submission time Handle Problem Language Result Execution time Memory
152046 2019-09-06T07:06:43 Z beso123 Vision Program (IOI19_vision) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
int h,w;
int to(int x,int y){
    int j=w*x+y;
    return j;
}
void construct_network(int H, int W, int K){
    h=H;
    w=W;
int ind=0,x,y,x2,y2;
for(int k=1;k<=H;k++){
        vector <int> v;
for(int i=1;i<=W;i++){
   int j=to(k,i);
   v.push_back(j);
}
int i=add_or(v);
if(i==1)
if(x==0){
    x=k;
else x2=k;
ind++
}

}
if(ind==1)
    x2=x;
    ind=0;
for(int k=1;k<=W;k++){
        vector <int> v;
for(int i=1;i<=H;i++){
   int j=to(i,k);
   v.push_back(j);
}
int i=add_or(v);
if(i==1)
if(y==0){
    y=k;
else y2=k;
ind++
}

}
if(ind==1)
    y2=y;
  int p=abs(x-x1)+abs(y-y1);
  if(p==k){
        vector <int> sab;
  sab.push_back(to(x,x1))l
    add_and(sab);
  }
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:23:1: error: expected '}' before 'else'
 else x2=k;
 ^~~~
vision.cpp:20:3: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
 if(i==1)
   ^
vision.cpp:25:1: error: expected ';' before '}' token
 }
 ^
vision.cpp:12:13: warning: unused variable 'y' [-Wunused-variable]
 int ind=0,x,y,x2,y2;
             ^
vision.cpp:12:18: warning: unused variable 'y2' [-Wunused-variable]
 int ind=0,x,y,x2,y2;
                  ^~
vision.cpp: At global scope:
vision.cpp:28:1: error: expected unqualified-id before 'if'
 if(ind==1)
 ^~
vision.cpp:30:5: error: 'ind' does not name a type; did you mean 'int'?
     ind=0;
     ^~~
     int
vision.cpp:31:1: error: expected unqualified-id before 'for'
 for(int k=1;k<=W;k++){
 ^~~
vision.cpp:31:13: error: 'k' does not name a type
 for(int k=1;k<=W;k++){
             ^
vision.cpp:31:18: error: 'k' does not name a type
 for(int k=1;k<=W;k++){
                  ^
vision.cpp:46:1: error: expected unqualified-id before 'if'
 if(ind==1)
 ^~
vision.cpp:48:13: error: 'x' was not declared in this scope
   int p=abs(x-x1)+abs(y-y1);
             ^
vision.cpp:48:15: error: 'x1' was not declared in this scope
   int p=abs(x-x1)+abs(y-y1);
               ^~
vision.cpp:48:15: note: suggested alternative: 'y1'
   int p=abs(x-x1)+abs(y-y1);
               ^~
               y1
vision.cpp:48:23: error: 'y' was not declared in this scope
   int p=abs(x-x1)+abs(y-y1);
                       ^
vision.cpp:49:3: error: expected unqualified-id before 'if'
   if(p==k){
   ^~
vision.cpp:54:1: error: expected declaration before '}' token
 }
 ^