답안 #281551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
281551 2020-08-23T07:48:51 Z neki CEOI16_icc (CEOI16_icc) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.h"
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 1000010
#define pa pair<ll, ll>
#define ld long double
vc<vc<ll>> dsu;

ll dsuque(vc<ll> a, vc<ll> b){
    vc<ll> qa, qb;
    fore(v, a) fore(u, dsu[v]) qa.ps(u);
    fore(v, b) fore(u, dsu[v]) qb.ps(u);
    return query(qa.size(), qb.size(), qa, qb);
}
pa solve(){
    
    vc<ll> fa, fb;
    if(dsu.size()==2){
        fa.ps(0);
        fb.ps(1);
    }
    else{
        vc<pa> arr[2];
        arr[0].ps(make_pair(0, dsu.size()));
        while(1){
            vc<pa> temp[2];
            fore(v, arr[0]){
                if(v.fi==v.se-1){
                    temp[0].ps(v);
                    continue;
                }
                ll mid=v.fi+v.se;mid/=2;
                temp[0].ps(make_pair(v.fi, mid));
                temp[1].ps(make_pair(mid, v.se));
            }
            fore(v, arr[1]){
                if(v.fi==v.se-1){
                    temp[1].ps(v);
                    continue;
                }
                ll mid=v.fi+v.se;mid/=2;
                temp[0].ps(make_pair(v.fi, mid));
                temp[1].ps(make_pair(mid, v.se));
            }
            arr[0]=temp[0];
            arr[1]=temp[1];
            vc<ll> a, b;
            fore(v, arr[0]) loop(i, v.fi, v.se) a.ps(i);
            fore(v, arr[1]) loop(i, v.fi, v.se) b.ps(i);
            if(dsuque(a, b)){
                fa=a, fb=b;
                break;
            }
        }
    }
    while(fa.size()>1){
        vc<ll> l[2];
        loop(i, 0, fa.size()) l[i%2].ps(fa[i]);
        if(dsuque(l[0], fb)) fa=l[0];
        else fa=l[1];
    }
    while(fb.size()>1){
        vc<ll> l[2];
        loop(i, 0, fb.size()) l[i%2].ps(fb[i]);
        if(dsuque(l[0], fa)) fb=l[0];
        else fb=l[1];
    }
    vc<ll> ta=dsu[fa[0]], tb=dsu[fb[0]];
    while(ta.size()>1){
        vc<ll> l[2];
        loop(i, 0, ta.size()) l[i%2].ps(ta[i]);
        if(query(l[0].size(), tb.size(), l[0], tb)) ta=l[0];
        else ta=l[1];
    }
    while(tb.size()>1){
        vc<ll> l[2];
        loop(i, 0, tb.size()) l[i%2].ps(tb[i]);
        if(query(l[0].size(), ta.size(), l[0], ta)) tb=l[0];
        else tb=l[1];
    }
    return make_pair(ta[0], tb[0]);
}
void run(ll n){
    loop(i, 1, n+1) dsu.ps(vc<ll> {i});
    loop(i, 0, n-1){
        pa ans=solve();
        ll a, b;vc<ll> temp;
        loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.fi) a=i;
        fore(v, dsu[a]) temp.ps(v);
        dsu.erase(dsu.begin()+a);
        
        loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.se) b=i;
        fore(v, dsu[b]) temp.ps(v);
        dsu.erase(dsu.begin()+b);
        
        dsu.ps(temp);
        
        setRoad(ans.fi, ans.se);
    }
}

Compilation message

icc.cpp: In function 'long long int dsuque(std::vector<long long int>, std::vector<long long int>)':
icc.cpp:29:40: error: cannot convert 'std::vector<long long int>' to 'int*'
   29 |     return query(qa.size(), qb.size(), qa, qb);
      |                                        ^~
      |                                        |
      |                                        std::vector<long long int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp: In function 'std::pair<long long int, long long int> solve()':
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
   74 |         loop(i, 0, fa.size()) l[i%2].ps(fa[i]);
      |              ~~~~~~~~~~~~~~~              
icc.cpp:74:9: note: in expansion of macro 'loop'
   74 |         loop(i, 0, fa.size()) l[i%2].ps(fa[i]);
      |         ^~~~
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
   80 |         loop(i, 0, fb.size()) l[i%2].ps(fb[i]);
      |              ~~~~~~~~~~~~~~~              
icc.cpp:80:9: note: in expansion of macro 'loop'
   80 |         loop(i, 0, fb.size()) l[i%2].ps(fb[i]);
      |         ^~~~
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
   87 |         loop(i, 0, ta.size()) l[i%2].ps(ta[i]);
      |              ~~~~~~~~~~~~~~~              
icc.cpp:87:9: note: in expansion of macro 'loop'
   87 |         loop(i, 0, ta.size()) l[i%2].ps(ta[i]);
      |         ^~~~
icc.cpp:88:45: error: cannot convert 'std::vector<long long int>' to 'int*'
   88 |         if(query(l[0].size(), tb.size(), l[0], tb)) ta=l[0];
      |                                          ~~~^
      |                                             |
      |                                             std::vector<long long int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
   93 |         loop(i, 0, tb.size()) l[i%2].ps(tb[i]);
      |              ~~~~~~~~~~~~~~~              
icc.cpp:93:9: note: in expansion of macro 'loop'
   93 |         loop(i, 0, tb.size()) l[i%2].ps(tb[i]);
      |         ^~~~
icc.cpp:94:45: error: cannot convert 'std::vector<long long int>' to 'int*'
   94 |         if(query(l[0].size(), ta.size(), l[0], ta)) tb=l[0];
      |                                          ~~~^
      |                                             |
      |                                             std::vector<long long int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp: In function 'void run(long long int)':
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
  104 |         loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.fi) a=i;
      |              ~~~~~~~~~~~~~~~~             
icc.cpp:104:9: note: in expansion of macro 'loop'
  104 |         loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.fi) a=i;
      |         ^~~~
icc.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
  108 |         loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.se) b=i;
      |              ~~~~~~~~~~~~~~~~             
icc.cpp:108:9: note: in expansion of macro 'loop'
  108 |         loop(i, 0, dsu.size()) fore(u, dsu[i]) if(u==ans.se) b=i;
      |         ^~~~