답안 #894817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894817 2023-12-29T04:25:36 Z Sir_Ahmed_Imran 분수 공원 (IOI21_parks) C++17
컴파일 오류
0 ms 0 KB
                              ///~~~LOTA~~~///
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 200001
int siz[N];
int par[N];
int root(int v){
    if(!par[v]) return v;
    par[v]=root(par[v]);
    return par[v];
}
void merge(int v,int u){
    v=root(v);
    u=root(u);
    par[u]=v;
    siz[v]+=siz[u];
}
bool same(int v,int u){
    return (root(v)==root(u));
}
int construct_roads(vector<int> x,vector<int> y){
    map<pii,int> c,z;
    int n,m,o,p,q,r;
    n=x.size();
    vector<int> v,u,w,a,b;
    for(int i=0;i<n;i++){
        w.append({{x[i],y[i]},i+1});
        z[{x[i],y[i]}]=i+1;
        siz[i+1]=1;
    }
    sort(all(w));
    for(auto& i:w){
        p=i.ff.ff;
        q=i.ff.ss;
        r=z[{p-2,q}];
        if(r){
            if(!same(i.ss,r)){
                merge(i.ss,r);
                v.append(i.ss-1);
                u.append(r-1);
                if(!c[{p-1,q-1}]){
                    a.append(p-1);
                    b.append(q-1);
                    c[{p-1,q-1}]=1;
                }
                else if(!c[{p-1,q+1}]){
                    a.append(p-1);
                    b.append(q+1);
                    c[{p-1,q+1}]=1;
                }
                else return 0;
            }
        }
        r=z[{p,q-2}];
        if(r){
            if(!same(i.ss,r)){
                merge(i.ss,r);
                v.append(i.ss-1);
                u.append(r-1);
                if(!c[{p-1,q-1}]){
                    a.append(p-1);
                    b.append(q-1);
                    c[{p-1,q-1}]=1;
                }
                else if(!c[{p+1,q-1}]){
                    a.append(p+1);
                    b.append(q-1);
                    c[{p+1,q-1}]=1;
                }
                else return 0;
            }
        }
    }
    if(siz[root(1)]!=n) return 0;
    build(u,v,a,b);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:35:35: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   35 |         w.append({{x[i],y[i]},i+1});
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from parks.h:1,
                 from parks.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
parks.cpp:6:12: error: request for member 'first' in 'i', which is of non-class type 'int'
    6 | #define ff first
      |            ^~~~~
parks.cpp:41:13: note: in expansion of macro 'ff'
   41 |         p=i.ff.ff;
      |             ^~
parks.cpp:6:12: error: request for member 'first' in 'i', which is of non-class type 'int'
    6 | #define ff first
      |            ^~~~~
parks.cpp:42:13: note: in expansion of macro 'ff'
   42 |         q=i.ff.ss;
      |             ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:45:24: note: in expansion of macro 'ss'
   45 |             if(!same(i.ss,r)){
      |                        ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:46:25: note: in expansion of macro 'ss'
   46 |                 merge(i.ss,r);
      |                         ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:47:28: note: in expansion of macro 'ss'
   47 |                 v.append(i.ss-1);
      |                            ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:64:24: note: in expansion of macro 'ss'
   64 |             if(!same(i.ss,r)){
      |                        ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:65:25: note: in expansion of macro 'ss'
   65 |                 merge(i.ss,r);
      |                         ^~
parks.cpp:7:12: error: request for member 'second' in 'i', which is of non-class type 'int'
    7 | #define ss second
      |            ^~~~~~
parks.cpp:66:28: note: in expansion of macro 'ss'
   66 |                 v.append(i.ss-1);
      |                            ^~
parks.cpp:31:11: warning: unused variable 'm' [-Wunused-variable]
   31 |     int n,m,o,p,q,r;
      |           ^
parks.cpp:31:13: warning: unused variable 'o' [-Wunused-variable]
   31 |     int n,m,o,p,q,r;
      |             ^