답안 #150664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150664 2019-09-01T08:48:00 Z graneli(#3789, toloraia) 갈라파고스 여행 (FXCUP4_island) C++17
컴파일 오류
0 ms 0 KB
#include "island.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
using namespace std;

const int N = 300005;
int n, m;
vector < int > V[N];
int par[N];
set < pair < int, int > > S[N];

void Init(int K, std::vector<int> F, std::vector<int> S, std::vector<int> E){
	n = F.size(), m = S.size();
	// ToDo
	for (int i = 0; i < n; i++){
        S[i].insert ({m, i});
        par[i] = i;
	}
	for (int i = m - 1; i >= 0; i--){
        int u = S[i], v = E[i];
        u = par[u];
        v = par[v];
        if (u == v)
            continue;
        if ((int)V[u].size() > (int)V[v].size())
            swap (u, v);
        for (int x : V[u]){
            par[x] = v;
            V[v].pb (x);
            S[x].insert ({i, v});
        }
        V[u].clear();
	}
}

int Separate(int A, int B){
    int l = 0, r = m - 1;
    while (l < r){
        int mid = l + r + 1 >> 1;
        int x, y;
        auto I = S[A].lower_bound ({mid, 0});
        x = (*I);
        I = S[B].lower_bound ({mid, 0});
        y = (*I);
        if (x == y)
            l = mid;
        else
            r = mid - 1;
    }
	return l;
}

Compilation message

island.cpp: In function 'void Init(int, std::vector<int>, std::vector<int>, std::vector<int>)':
island.cpp:27:14: error: request for member 'insert' in 'second.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
         S[i].insert ({m, i});
              ^~~~~~
island.cpp:41:18: error: request for member 'insert' in 'second.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
             S[x].insert ({i, v});
                  ^~~~~~
island.cpp: In function 'int Separate(int, int)':
island.cpp:50:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = l + r + 1 >> 1;
                   ~~~~~~^~~
island.cpp:53:16: error: cannot convert 'const std::pair<int, int>' to 'int' in assignment
         x = (*I);
                ^
island.cpp:55:16: error: cannot convert 'const std::pair<int, int>' to 'int' in assignment
         y = (*I);
                ^