답안 #491679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491679 2021-12-03T19:02:34 Z MeGustaElArroz23 분수 공원 (IOI21_parks) C++17
컴파일 오류
0 ms 0 KB
#include "parks.h"

#include<bits/stdc++.h>

#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define fi first
#define se second

int construct_roads(vi cordx, vi cordy){
    int n=cordx.size();
    vii v(n);
    for (int i=0;i<n;i++) v[i]=pii{cordx[i],cordy[i]};

    vi u; //ind fuentes
    vi w;
    vi a; // coord banco
    vi b;

    map<pii,int> indfuente;
    for (int i=0;i<n;i++) indfuente[v[i]]=i+1;

    set<pii> posiblesbancos;
    for (pii p:v){
        posiblesbancos.insert(pii{p.fi+1,p.se+1});
        posiblesbancos.insert(pii{p.fi+1,p.se-1});
        posiblesbancos.insert(pii{p.fi-1,p.se+1});
        posiblesbancos.insert(pii{p.fi-1,p.se-1});
    }

    for (pii p:posiblesbancos){
        if ((p.fi+p.se)%4==0){
            if (indfuente[pii{p.fi+1,p.se+1}] && indfuente[pii{p.fi-1,p.se+1}]){
                u.push_back(indfuente[pii{p.fi+1,p.se+1}]-1);
                w.push_back(indfuente[pii{p.fi-1,p.se+1}]-1);
                a.push_back(p.fi);
                b.push_back(p.se);
            }
            else if (indfuente[pii{p.fi+1,p.se-1}] && indfuente[pii{p.fi-1,p.se-1}]){
                u.push_back(indfuente[pii{p.fi+1,p.se-1}]-1);
                w.push_back(indfuente[pii{p.fi-1,p.se-1}]-1);
                a.push_back(p.fi);
                b.push_back(p.se);
            }
        }
        else{
            if (indfuente[pii{p.fi+1,p.se+1}] && indfuente[pii{p.fi+1,p.se-1}]){
                u.push_back(indfuente[pii{p.fi+1,p.se+1}]-1);
                w.push_back(indfuente[pii{p.fi+1,p.se-1}]-1);
                a.push_back(p.fi);
                b.push_back(p.se);
            }
            else if (indfuente[pii{p.fi-1,p.se+1}] && indfuente[pii{p.fi-1,p.se-1}]){
                u.push_back(indfuente[pii{p.fi-1,p.se+1}]-1);
                w.push_back(indfuente[pii{p.fi-1,p.se-1}]-1);
                a.push_back(p.fi);
                b.push_back(p.se);
            }
        }
    }

    if (u.size()<n-1) return 0;

    build(u,w,a,b);
 
    return 1;
}

Compilation message

parks.cpp:5:12: error: 'int construct_roads' redeclared as different kind of entity
    5 | #define vi vector<int>
      |            ^~~~~~
parks.cpp:11:21: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                     ^~
In file included from parks.cpp:1:
parks.h:3:5: note: previous declaration 'int construct_roads(std::vector<int>, std::vector<int>)'
    3 | int construct_roads(std::vector<int> x, std::vector<int> y);
      |     ^~~~~~~~~~~~~~~
parks.cpp:5:12: error: 'vector' was not declared in this scope
    5 | #define vi vector<int>
      |            ^~~~~~
parks.cpp:11:21: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                     ^~
parks.cpp:5:12: note: suggested alternatives:
    5 | #define vi vector<int>
      |            ^~~~~~
parks.cpp:11:21: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                     ^~
In file included from /usr/include/c++/10/vector:67,
                 from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
parks.cpp:5:19: error: expected primary-expression before 'int'
    5 | #define vi vector<int>
      |                   ^~~
parks.cpp:11:21: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                     ^~
parks.cpp:5:12: error: 'vector' was not declared in this scope
    5 | #define vi vector<int>
      |            ^~~~~~
parks.cpp:11:31: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                               ^~
parks.cpp:5:12: note: suggested alternatives:
    5 | #define vi vector<int>
      |            ^~~~~~
parks.cpp:11:31: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                               ^~
In file included from /usr/include/c++/10/vector:67,
                 from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
parks.cpp:5:19: error: expected primary-expression before 'int'
    5 | #define vi vector<int>
      |                   ^~~
parks.cpp:11:31: note: in expansion of macro 'vi'
   11 | int construct_roads(vi cordx, vi cordy){
      |                               ^~