Submission #907275

# Submission time Handle Problem Language Result Execution time Memory
907275 2024-01-15T10:45:21 Z NemanjaSo2005 Fence (CEOI08_fence) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define int log long
using namespace std;
int N,M;
struct tacka{
   ll x,y;
   bool operator == (const tacka &a){
      return x==a.x and y==a.y;
   }
   tacka operator - (const tacka &a){
      tacka ret;
      ret.x=x-a.x;
      ret.y=y-a.y;
      return ret;
   }
   tacka operator + (const tacka &a){
      tacka ret;
      ret.x=x+a.x;
      ret.y=y+a.y;
      return ret;
   }
} R[105],G[105];
ll znak(ll x){
   if(x==0)
      return 0;
   if(x>0)
      return 1;
   return -1;
}
ll orijent(tacka p1,tacka p2,tacka a){
   if(p1.x==p2.x)
      return znak(p2.y-p1.y)*znak(p1.x-a.x)*-1;
   return znak((p2.y-a.y)*(p2.x-p1.x)-(p2.x-a.x)*(p2.y-p1.y));
}
bool inpolyg(vector<tacka> V,tacka p){
   V.push_back(V[0]);
   int ort=orijent(V[0],V[1],p);
   for(int i=2;i<V.size();i++)
      if(ort!=orijent(V[i-1],V[i],p))
         return false;
   return true;
}
bool svelevo(tacka p1,tacka p2){
   for(int i=1;i<=M;i++)
      if(orijent(p1,p2,G[i])==-1){
         return false;
      }
   return true;
}
bool pox(tacka a,tacka b){
   if(a.x<b.x)
      return true;
   if(a.x>b.x)
      return false;
   return a.y<b.y;
}
vector<tacka> make_hull(vector<tacka> V){
   sort(V.begin(),V.end(),pox);
   vector<tacka> R;
   R.push_back(V[0]);
   for(int i=1;i<V.size();i++){
      if(V[i].x==V[0].x)
         continue;
      while(R.size()>=2){
         tacka p2=R.back();
         R.pop_back();
         tacka p1=R.back();
         R.push_back(p2);
         if(orijent(p1,p2,V[i])<0)
            break;
         R.pop_back();
      }
      R.push_back(V[i]);
   }

   tacka spec=R.back();
   for(int i=0;i<V.size();i++){
      if(V[i].x==R.back().x and V[i].y>spec.y)
         spec=V[i];
   }
   if(!(spec==R.back()))
      R.push_back(spec);

   for(int i=V.size()-1;i>=0;i--){
      if(V[i].x==R.back().x)
         continue;
      while(R.size()>=2){
         tacka p2=R.back();
         R.pop_back();
         tacka p1=R.back();
         R.push_back(p2);
         if(orijent(p1,p2,V[i])<0)
            break;
         R.pop_back();
      }
      R.push_back(V[i]);
   }
   if(R[0]==R.back())
      R.pop_back();
   return R;
}
vector<int> graf[105];
int prosli[105],pvred,res=1000;
void bfs(int start, int goal) {
    queue<pair<int, int>> q;
    q.push({start, 0}); 
    while (!q.empty()) {
        int current = q.front().first;
        int distance = q.front().second;
        q.pop();
        if (current == goal && distance != 0) {
            res = min(res, distance);
            continue;
        }
        if (prosli[current] == pvred) {
            continue;
        }
        prosli[current] = pvred;
        for (int neighbor : graf[current]) {
            q.push({neighbor, distance + 1});
        }
    }
}
signed main(){
   cin>>N>>M;
   int oM=M;
   for(int i=1;i<=N;i++)
      cin>>R[i].x>>R[i].y;
   for(int i=1;i<=M;i++)
      cin>>G[i].x>>G[i].y;
   vector<tacka> V;
   for(int i=1;i<=N;i++)
      V.push_back(R[i]);
   V=make_hull(V);

   for(int i=1;i<=M;i++)
      if(!inpolyg(V,G[i])){
         swap(G[M],G[i]);
         M--;
         i--;
      }

   for(int i=1;i<=N;i++)
      for(int j=1;j<=N;j++){
         if(i==j)
            continue;
        // cout<<i<<" "<<j<<endl;
         if(svelevo(R[i],R[j]))
            graf[i].push_back(j);
      }

   for(int i=1;i<=N;i++){
      pvred++;
      bfs(i,i);
   }

   cout<<(oM-M)*111+res*20<<endl;
   return 0;
}

Compilation message

fence.cpp:3:13: error: 'log' does not name a type
    3 | #define int log long
      |             ^~~
fence.cpp:5:1: note: in expansion of macro 'int'
    5 | int N,M;
      | ^~~
fence.cpp: In function 'bool inpolyg(std::vector<tacka>, tacka)':
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:38:4: note: in expansion of macro 'int'
   38 |    int ort=orijent(V[0],V[1],p);
      |    ^~~
fence.cpp:38:32: error: statement cannot resolve address of overloaded function
   38 |    int ort=orijent(V[0],V[1],p);
      |                                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:39:8: note: in expansion of macro 'int'
   39 |    for(int i=2;i<V.size();i++)
      |        ^~~
fence.cpp:39:15: error: statement cannot resolve address of overloaded function
   39 |    for(int i=2;i<V.size();i++)
      |               ^
fence.cpp:39:16: error: 'i' was not declared in this scope
   39 |    for(int i=2;i<V.size();i++)
      |                ^
fence.cpp:40:10: error: 'ort' was not declared in this scope; did you mean 'qsort'?
   40 |       if(ort!=orijent(V[i-1],V[i],p))
      |          ^~~
      |          qsort
fence.cpp: In function 'bool svelevo(tacka, tacka)':
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:45:8: note: in expansion of macro 'int'
   45 |    for(int i=1;i<=M;i++)
      |        ^~~
fence.cpp:45:15: error: statement cannot resolve address of overloaded function
   45 |    for(int i=1;i<=M;i++)
      |               ^
fence.cpp:45:16: error: 'i' was not declared in this scope
   45 |    for(int i=1;i<=M;i++)
      |                ^
fence.cpp:45:19: error: 'M' was not declared in this scope
   45 |    for(int i=1;i<=M;i++)
      |                   ^
fence.cpp: In function 'std::vector<tacka> make_hull(std::vector<tacka>)':
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:62:8: note: in expansion of macro 'int'
   62 |    for(int i=1;i<V.size();i++){
      |        ^~~
fence.cpp:62:15: error: statement cannot resolve address of overloaded function
   62 |    for(int i=1;i<V.size();i++){
      |               ^
fence.cpp:62:16: error: 'i' was not declared in this scope
   62 |    for(int i=1;i<V.size();i++){
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:78:8: note: in expansion of macro 'int'
   78 |    for(int i=0;i<V.size();i++){
      |        ^~~
fence.cpp:78:15: error: statement cannot resolve address of overloaded function
   78 |    for(int i=0;i<V.size();i++){
      |               ^
fence.cpp:78:16: error: 'i' was not declared in this scope
   78 |    for(int i=0;i<V.size();i++){
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:85:8: note: in expansion of macro 'int'
   85 |    for(int i=V.size()-1;i>=0;i--){
      |        ^~~
fence.cpp:85:24: error: statement cannot resolve address of overloaded function
   85 |    for(int i=V.size()-1;i>=0;i--){
      |                        ^
fence.cpp:85:25: error: 'i' was not declared in this scope
   85 |    for(int i=V.size()-1;i>=0;i--){
      |                         ^
fence.cpp: At global scope:
fence.cpp:103:11: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
  103 | vector<int> graf[105];
      |           ^
fence.cpp:103:11: note:   expected a type, got 'std::log'
fence.cpp:103:11: error: template argument 2 is invalid
fence.cpp:3:13: error: 'log' does not name a type
    3 | #define int log long
      |             ^~~
fence.cpp:104:1: note: in expansion of macro 'int'
  104 | int prosli[105],pvred,res=1000;
      | ^~~
fence.cpp:105:6: error: variable or field 'bfs' declared void
  105 | void bfs(int start, int goal) {
      |      ^~~
fence.cpp:3:17: error: expected ')' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:105:10: note: in expansion of macro 'int'
  105 | void bfs(int start, int goal) {
      |          ^~~
fence.cpp:105:9: note: to match this '('
  105 | void bfs(int start, int goal) {
      |         ^
fence.cpp:3:17: error: expected ')' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:105:21: note: in expansion of macro 'int'
  105 | void bfs(int start, int goal) {
      |                     ^~~
fence.cpp:105:9: note: to match this '('
  105 | void bfs(int start, int goal) {
      |         ^
fence.cpp: In function 'int main()':
fence.cpp:126:9: error: 'N' was not declared in this scope
  126 |    cin>>N>>M;
      |         ^
fence.cpp:126:12: error: 'M' was not declared in this scope
  126 |    cin>>N>>M;
      |            ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:127:4: note: in expansion of macro 'int'
  127 |    int oM=M;
      |    ^~~
fence.cpp:127:12: error: statement cannot resolve address of overloaded function
  127 |    int oM=M;
      |            ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:128:8: note: in expansion of macro 'int'
  128 |    for(int i=1;i<=N;i++)
      |        ^~~
fence.cpp:128:15: error: statement cannot resolve address of overloaded function
  128 |    for(int i=1;i<=N;i++)
      |               ^
fence.cpp:128:16: error: 'i' was not declared in this scope
  128 |    for(int i=1;i<=N;i++)
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:130:8: note: in expansion of macro 'int'
  130 |    for(int i=1;i<=M;i++)
      |        ^~~
fence.cpp:130:15: error: statement cannot resolve address of overloaded function
  130 |    for(int i=1;i<=M;i++)
      |               ^
fence.cpp:130:16: error: 'i' was not declared in this scope
  130 |    for(int i=1;i<=M;i++)
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:133:8: note: in expansion of macro 'int'
  133 |    for(int i=1;i<=N;i++)
      |        ^~~
fence.cpp:133:15: error: statement cannot resolve address of overloaded function
  133 |    for(int i=1;i<=N;i++)
      |               ^
fence.cpp:133:16: error: 'i' was not declared in this scope
  133 |    for(int i=1;i<=N;i++)
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:137:8: note: in expansion of macro 'int'
  137 |    for(int i=1;i<=M;i++)
      |        ^~~
fence.cpp:137:15: error: statement cannot resolve address of overloaded function
  137 |    for(int i=1;i<=M;i++)
      |               ^
fence.cpp:137:16: error: 'i' was not declared in this scope
  137 |    for(int i=1;i<=M;i++)
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:144:8: note: in expansion of macro 'int'
  144 |    for(int i=1;i<=N;i++)
      |        ^~~
fence.cpp:144:15: error: statement cannot resolve address of overloaded function
  144 |    for(int i=1;i<=N;i++)
      |               ^
fence.cpp:144:16: error: 'i' was not declared in this scope
  144 |    for(int i=1;i<=N;i++)
      |                ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:145:11: note: in expansion of macro 'int'
  145 |       for(int j=1;j<=N;j++){
      |           ^~~
fence.cpp:145:18: error: statement cannot resolve address of overloaded function
  145 |       for(int j=1;j<=N;j++){
      |                  ^
fence.cpp:145:19: error: 'j' was not declared in this scope
  145 |       for(int j=1;j<=N;j++){
      |                   ^
fence.cpp:3:17: error: expected ';' before 'long'
    3 | #define int log long
      |                 ^~~~
fence.cpp:153:8: note: in expansion of macro 'int'
  153 |    for(int i=1;i<=N;i++){
      |        ^~~
fence.cpp:153:15: error: statement cannot resolve address of overloaded function
  153 |    for(int i=1;i<=N;i++){
      |               ^
fence.cpp:153:16: error: 'i' was not declared in this scope
  153 |    for(int i=1;i<=N;i++){
      |                ^
fence.cpp:154:7: error: 'pvred' was not declared in this scope
  154 |       pvred++;
      |       ^~~~~
fence.cpp:155:7: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
  155 |       bfs(i,i);
      |       ^~~
      |       ffs
fence.cpp:158:11: error: 'oM' was not declared in this scope
  158 |    cout<<(oM-M)*111+res*20<<endl;
      |           ^~
fence.cpp:158:21: error: 'res' was not declared in this scope
  158 |    cout<<(oM-M)*111+res*20<<endl;
      |                     ^~~