Submission #733942

# Submission time Handle Problem Language Result Execution time Memory
733942 2023-05-01T12:17:53 Z vjudge1 City Mapping (NOI18_citymapping) C++17
Compilation error
0 ms 0 KB
#include "citymapping.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
    out << c.first << ' ' << c.second;
    return out;
}

template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
    const int sz = v.size();
    for (int i = 0; i < sz; i++) {
        if (i) out << ' ';
        out << v[i];
    }
    return out;
}

template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
    for (T &x : v) in >> x;
    return in;
}

template<typename T>
void mxx(T &a, T b){if(b > a) a = b;}
template<typename T>
void mnn(T &a, T b){if(b < a) a = b;}

void find_roads(int n, int Q, int A[], int B[], int W[]) {
	queue<pair<int, vector<int>>> q;
	vector<ll> dis(n + 1, 0);
	vector<int> tmp;

	int sum = 0;

	auto get = [&](int x, int y) -> ll {
		sum++;
		return get_distance(x, y);
	};

	for(int i = 2; i <= n; i++) {
		dis[i] = get(1, i);
		tmp.pb(i);
	}
	q.push({1, tmp});
	int cnt = 0;

	auto add = [&](int a, int b, int w) -> void {
		A[cnt] = a;
		B[cnt] = b;
		W[cnt++] = w;
	};

	while(q.size()) {
		int x = q.front().ff;
		tmp = q.front().ss;
		q.pop();
		sort(all(tmp), [&](int xx, int yy) -> bool {
			return dis[xx] < dis[yy];
		});
		vector<pair<int, vector<int>>> c;
		for(int y : tmp) {
			if(c.size() == 0) {c.pb({y, vector<int>()}); add(x, y, dis[y] - dis[x]);}
			else {
				bool did = 0;
				for(auto &it : c) {
					if(dis[y] - dis[x] * 2 - (dis[it.ff] - dis[x]) * 2 == dis[y] - dis[it.ff]) {
						it.ss.pb(y);
						did = 1;
						break;
					}
				}
				if(!did) {
					ll mn = dis[y] - dis[x];
					int par = x;
					// int cnt = 0, id = -1;
					// for(auto &it : c) {
					// 	ll val = get(y, it.ff);
					// 	if(val < mn) {
					// 		mn = val;
					// 		par = it.ff;
					// 		id = cnt;
					// 	}
					// 	cnt++;
					// }
					if(par == x) {
						add(x, y, mn);
						c.pb({y, vector<int>()});
					} else {
						c[id].ss.pb(y);
					}
				}
			}
		}
		while(c.size()) {
			q.push(c.back());
			c.pop_back();
		}
	}
	assert(sum <= q);
	// assert(cnt == n - 1);
	return;
}

Compilation message

citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:110:9: error: 'id' was not declared in this scope; did you mean 'did'?
  110 |       c[id].ss.pb(y);
      |         ^~
      |         did
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:13: error: no match for 'operator<=' (operand types are 'int' and 'std::queue<std::pair<int, std::vector<int> > >')
  120 |  assert(sum <= q);
      |         ~~~ ^~ ~
      |         |      |
      |         int    std::queue<std::pair<int, std::vector<int> > >
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1086:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)'
 1086 |     operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1086:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1192:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)'
 1192 |     operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1192:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1285:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1285 |     operator<=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1285:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1359:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)'
 1359 |     operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1359:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   'std::queue<std::pair<int, std::vector<int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1453:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1453 |     operator<=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1453:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1531:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)'
 1531 |     operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1531:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   'std::queue<std::pair<int, std::vector<int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/regex.h:1631:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1631 |     operator<=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1631:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:508:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  508 |     operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:508:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/stl_iterator.h:384:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  384 |     operator<=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:384:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/stl_iterator.h:422:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  422 |     operator<=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:422:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/stl_iterator.h:1460:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1460 |     operator<=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1460:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/stl_iterator.h:1513:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1513 |     operator<=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1513:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from citymapping.cpp:2:
/usr/include/c++/10/string_view:582:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)'
  582 |     operator<=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:582:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from citymapping.cpp:2:
/usr/include/c++/10/string_view:588:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(std::basic_string_view<_CharT, _Traits>, std::__type_identity_t<std::basic_string_view<_CharT, _Traits> >)'
  588 |     operator<=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:588:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from citymapping.cpp:2:
/usr/include/c++/10/string_view:595:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(std::__type_identity_t<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)'
  595 |     operator<=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:595:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   'std::queue<std::pair<int, std::vector<int> > >' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6343:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 6343 |     operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6343:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from citymapping.cpp:2:
citymapping.cpp:120:16: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
  120 |  assert(sum <= q);
      |                ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from citymapping.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6356:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 6356 |     operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~