submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s323403224
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int first, second; }edges2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } signed main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> edges2.first >> edges2.second; } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'int main()': a.cc:101:31: error: request for member 'first' in 'edges2', which is of non-class type 'data [100001]' 101 | cin >> edges2.first >> edges2.second; | ^~~~~ a.cc:101:47: error: request for member 'second' in 'edges2', which is of non-class type 'data [100001]' 101 | cin >> edges2.first >> edges2.second; | ^~~~~~ a.cc:105:137: error: expected ')' before ';' token 105 | for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ~ ^ | ) a.cc:107:137: error: expected ')' before ';' token 107 | for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ~ ^ | ) a.cc:108:18: error: 'g' was not declared in this scope 108 | int mst_wt = g.kruskalMST(); | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'data' to 'long long int' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(long long int, long long int)>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'data' to 'long long int' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(long long int, long long int)>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 190
s024231867
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int first, second; }edges2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } signed main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> edges2[i].first >> edges2[i].second; } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'int main()': a.cc:105:39: error: expected unqualified-id before '.' token 105 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:107:39: error: expected unqualified-id before '.' token 107 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:108:18: error: 'g' was not declared in this scope 108 | int mst_wt = g.kruskalMST(); | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'data' to 'long long int' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(long long int, long long int)>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'data' to 'long long int' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(long long int, long long int)>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:196:30: error: cannot convert 'data' to 'long long int' in argument passing 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~
s367649332
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int x, y, weight; }edges2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } signed main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> x >> y; edges2.push_back(make_pair(x, y)); } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'bool cmp1(long long int, long long int)': a.cc:28:22: error: 'struct data' has no member named 'first' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~ a.cc:28:40: error: 'struct data' has no member named 'first' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~ a.cc:28:60: error: 'struct data' has no member named 'second' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~~ a.cc:28:79: error: 'struct data' has no member named 'second' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~~ a.cc:28:99: error: 'struct data' has no member named 'first' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~ a.cc:28:118: error: 'struct data' has no member named 'first' 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~ a.cc: In function 'bool cmp2(long long int, long long int)': a.cc:33:22: error: 'struct data' has no member named 'second' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~~ a.cc:33:41: error: 'struct data' has no member named 'second' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~~ a.cc:33:62: error: 'struct data' has no member named 'first' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~ a.cc:33:80: error: 'struct data' has no member named 'first' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~ a.cc:33:99: error: 'struct data' has no member named 'second' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~~ a.cc:33:119: error: 'struct data' has no member named 'second' 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~~ a.cc: In function 'int main()': a.cc:102:24: error: request for member 'push_back' in 'edges2', which is of non-class type 'data [100001]' 102 | edges2.push_back(make_pair(x, y)); | ^~~~~~~~~ a.cc:106:39: error: expected unqualified-id before '.' token 106 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:108:39: error: expected unqualified-id before '.' token 108 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:109:18: error: 'g' was not declared in this scope 109 | int mst_wt = g.kruskalMST(); | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:105:9: required from here 105 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'data' to 'long long int' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(long long int, long long int)>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:105:9: required from here 105 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'data' to 'long long int' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(long long int, long long int)>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) |
s712879753
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int x, y, weight; }edge2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } int main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> x >> y; edges2.push_back(make_pair(x, y)); } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'bool cmp1(long long int, long long int)': a.cc:28:12: error: 'edges2' was not declared in this scope; did you mean 'edge2'? 28 | if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; | ^~~~~~ | edge2 a.cc: In function 'bool cmp2(long long int, long long int)': a.cc:33:12: error: 'edges2' was not declared in this scope; did you mean 'edge2'? 33 | if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; | ^~~~~~ | edge2 At global scope: cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:102:17: error: 'edges2' was not declared in this scope; did you mean 'edge2'? 102 | edges2.push_back(make_pair(x, y)); | ^~~~~~ | edge2 a.cc:105:10: error: 'edges2' was not declared in this scope; did you mean 'edge2'? 105 | sort(edges2, edges2 + n, cmp1); | ^~~~~~ | edge2 a.cc:106:39: error: expected unqualified-id before '.' token 106 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:108:39: error: expected unqualified-id before '.' token 108 | for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); | ^ a.cc:109:18: error: 'g' was not declared in this scope 109 | int mst_wt = g.kruskalMST(); | ^ a.cc: In function 'bool cmp1(long long int, long long int)': a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type] 30 | } | ^ a.cc: In function 'bool cmp2(long long int, long long int)': a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type] 35 | } | ^
s649432188
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; vector< iPair > edges2; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } int main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> x >> y; edges2.push_back(make_pair(x, y)); } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second)); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:103:25: error: no match for 'operator+' (operand types are 'std::vector<std::pair<long long int, long long int> >' and 'long long int') 103 | sort(edges2, edges2 + n, cmp1); | ~~~~~~ ^ ~ | | | | | long long int | std::vector<std::pair<long long int, long long int> > In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 103 | sort(edges2, edges2 + n, cmp1); | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'const _CharT*' and 'std::vector<std::pair<long long int, long long int> >' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'const _CharT*' and 'std::vector<std::pair<long long int, long long int> >' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:103:27: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 103 | sort(edges2, edges2 + n, cmp1); | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:103:27: note: 'std::vector<std::pair<long long int, long long int> >' is not derive
s362889829
p03684
C++
#include <bits/stdc++.h> #define int long long #define mod 1000000007 #define lim 100001 using namespace std; struct point { int x,y,id; } c[lim]; struct edge { int u,v,cost; } e[2*lim]; bool cmp1(point a,point b) { return a.x < b.x; } bool cmp2(point a,point b) { return a.y < b.y; } bool cmp_edge(edge a,edge b) { return a.cost < b.cost; } int parent[lim]; int find(int x){return p[x] == x ? x : p[x] = find(p[x]);} int n,tot; signed main() { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin >> n; for(int i = 0; i <= n; i++) p[i] = i; for(int i = 1; i <= n; i++){ cin >> dx[i] >> dy[i]; } for(int i = 1; i <= n; i++) { c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i; } sort(c+1,c+1+n,cmp1); for(int i = 2; i <= n; i++){ e[tot].u = c[i].id; e[tot].v = c[i-1].id; e[tot].cost = c[i].x - c[i-1].x; tot++; } sort(c+1,c+1+n,cmp2); for(int i = 2; i <= n; i++){ e[tot].u = c[i].id; e[tot].v = c[i-1].id; e[tot].cost = c[i].y - c[i-1].y; tot++; } sort(e,e+tot,cmp); ll ans = 0; int cnt = 0; for(int i = 0; i < tot; i++){ int f = find(e[i].u); int t = find(e[i].v); if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;} if(cnt == n-1)break; } printf("%lld\n", ans); return 0; }
a.cc: In function 'long long int find(long long int)': a.cc:27:24: error: 'p' was not declared in this scope 27 | int find(int x){return p[x] == x ? x : p[x] = find(p[x]);} | ^ a.cc: In function 'int main()': a.cc:34:31: error: 'p' was not declared in this scope 34 | for(int i = 0; i <= n; i++) p[i] = i; | ^ a.cc:36:11: error: 'dx' was not declared in this scope 36 | cin >> dx[i] >> dy[i]; | ^~ a.cc:36:20: error: 'dy' was not declared in this scope 36 | cin >> dx[i] >> dy[i]; | ^~ a.cc:40:14: error: 'dx' was not declared in this scope 40 | c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i; | ^~ a.cc:40:30: error: 'dy' was not declared in this scope 40 | c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i; | ^~ a.cc:56:16: error: 'cmp' was not declared in this scope; did you mean 'cmp2'? 56 | sort(e,e+tot,cmp); | ^~~ | cmp2 a.cc:57:3: error: 'll' was not declared in this scope 57 | ll ans = 0; | ^~ a.cc:62:14: error: 'ans' was not declared in this scope; did you mean 'abs'? 62 | if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;} | ^~~ | abs a.cc:62:29: error: 'p' was not declared in this scope 62 | if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;} | ^ a.cc:65:20: error: 'ans' was not declared in this scope; did you mean 'abs'? 65 | printf("%lld\n", ans); | ^~~ | abs
s911833614
p03684
C++
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define int long long typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii; typedef vector< pair < int , pair < ii , ii > > > viiiii; map <ii,int> r; map<ii,ii> p; viiiii edge; int numset; ii a[100005]; void init(int N) { numset=N; for(int i=0 ; i<N ; i++) { p[a[i]] = a[i]; } } ii find(ii i) { if(p[i].fi == i.fi && p[i].se == i.se) return p[i]; else return find(p[i]); } bool same(ii i, ii j) { ii u = find(i); ii v = find(j); if(u .fi == v .fi && u .se == v .se) return 1; return 0; } void joint(ii i, ii j) { if(same(i,j)==0) { numset--; r[find(j)]+=r[find(i)]; p[find(i)]=find(j); } } int size(ii i) { return r[find(i)]; } int kruskal(int V) { sort(edge.begin(),edge.end()); init(V); int cost = 0; for(int i=0 ; i < edge.size(); i++) { pair < int , pair < ii , ii > > front = edge[i]; if(same(front.se.fi,front.se.se) == 0) { cost += front.fi; joint(front.se.fi,front.se.se); } } return cost; } bool cmp(ii a , ii b) { return a . se < b .se; } signed main(){ int n; cin >> n; for(int i = 1 ; i <= n ; ++i) { int x, y; cin >> x >> y; r[a[i]] = 1; a[i].fi = x; a[i].se = y; } sort(a + 1, a + n + 1); for(int i = 1 ; i < n ; ++i) { for(int j = i + 1 ; j <= i + 50 && j <= n ; ++j) { edge.pb(mp(a[j].fi - a[i].fi,mp(a[i],a[j]))); } } sort(a + 1, a + n + 1, cmp); for(int i = 1 ; i < n ; ++i) { for(int j = i + 1 ;j <= i + 50 && j <= n; ++j) { edge.pb(mp(a[j].se - a[i].se,mp(a[i],a[j]))); } } co
a.cc: In function 'int main()': a.cc:99:9: error: 'co' was not declared in this scope; did you mean 'cos'? 99 | co | ^~ | cos a.cc:99:11: error: expected '}' at end of input 99 | co | ^ a.cc:72:14: note: to match this '{' 72 | signed main(){ | ^
s464733249
p03684
C++
#include<cstdio> #include<algorithm> using namespace std; long long n,m,i,j,k,cc[500000],a,b,c,s ; long long min(long long x,long long y){ if (x>y) return y; else return x; } long long abs(long long x){ if (x<0) return -x; else return x; } struct p{ long long x,y,z; bool operator < (const p& tt) const{ return x<tt.x; } }s1[500000],s2[500000]; struct pp{ long long x,y,z; bool operator < (const pp& tt) const{ return z<tt.z; } }wow[1000000]; long long find(long long x){ if (cc[x]==x) return x; else { cc[x]= find(cc[x]); return cc[x]; } } int main(){ scanf("%lld",&n); for (int i=1;i<=n;i++){ scanf("%lld %lld",&s1[i].x,&s1[i].y); s2[i].x=s1[i].y; s2[i].y=s1[i].x; s1[i].z=i; s2[i].z=i; } sort(s1,s1+n+1); sort(s2,s2+n+1); a=0; for (int i=1;i<n;i++){ a++; wow[i].x=s1[i].z; wow[i].y=s1[i+1].z; wow[i].z=min(abs(s1[i+1].x-s1[i].x),abs(s1[i+1].y-s1[i].y)); } for (int i=1;i<n;i++){ a++; wow[a].x=s2[i].z; wow[a].y=s2[i+1].z; wow[a].z=min(abs(s2[i+1].x-s2[i].x),abs(s2[i+1].y-s2[i].y)); } sort(wow,wow+a+1); // for (int i=1;i<=a;i++) printf("%d %d %d\n",wow[i].x,wow[i].y,wow[i].z); for (int i=1;i<=n;i++) cc[i]=i; for (int i=1;i<=a;i++){ if (find(cc[wow[i].x])!=find(cc[wow[i].y])){ cc[find(cc[wow[i].x])]=find(cc[wow[i].y]); s+=wow[i].z; } } printf("%lld\n",s); return 0; }
a.cc: In function 'int main()': a.cc:49:33: error: call of overloaded 'abs(long long int)' is ambiguous 49 | wow[i].z=min(abs(s1[i+1].x-s1[i].x),abs(s1[i+1].y-s1[i].y)); | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/bits/stl_algo.h:71, from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:49:56: error: call of overloaded 'abs(long long int)' is ambiguous 49 | wow[i].z=min(abs(s1[i+1].x-s1[i].x),abs(s1[i+1].y-s1[i].y)); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:55:33: error: call of overloaded 'abs(long long int)' is ambiguous 55 | wow[a].z=min(abs(s2[i+1].x-s2[i].x),abs(s2[i+1].y-s2[i].y)); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:55:56: error: call of overloaded 'abs(long long int)' is ambiguous 55 | wow[a].z=min(abs(s2[i+1].x-s2[i].x),abs(s2[i+1].y-s2[i].y)); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~
s976412394
p03684
C++
#include<iostream> #include<vector> #include<algorithm> #define int long long using namespace std; const int N=1e5+100; int u[N],n,ans; class edge { public: int f,t,w; edge(int f,int t,int w):f(f),t(t),w(w){} }; class ufind { vector<int> f,r; public: ufind(int n) { f.reserve(N); r.assign(N,1); for(int i=1;i<=n;++i) f[i]=i; } int find(int x) { if (x==f[x]) return x; else x=f[x]; } bool unite(int x,int y) { x=find(x);y=find(y); if (x==y) return false; if (r[x]<r[y]) swap(x,y); f[y]=x; if (r[x]==r[y]) r[x]++; return true; } }; int main() { ios::sync_with_stdio(false); cin>>n; vector<pair<int,int>> x,y; for(int i=1;i<=n;++i) { int xx,yy; cin>>xx>>yy; x.push_back(make_pair(xx,i)); y.push_back(make_pair(yy,i)); } sort(x.begin(),x.end()); sort(y.begin(),y.end()); vector<edge> e; for(int i=1;i<n;++i) { e.push_back(edge(x[i-1].second,x[i].second,x[i].first-x[i-1].first)); e.push_back(edge(y[i-1].second,y[i].second,y[i].first-y[i-1].first)); e.push_back(edge(x[i].second,x[i-1].second,x[i].first-x[i-1].first)); e.push_back(edge(y[i].second,y[i-1].second,y[i].first-y[i-1].first)); } sort(e.begin(),e.end(),[](const edge &a,const edge &b){return a.w<b.w;}); ufind s(n); cout<<e.size()<<endl; for(auto i:e) if(s.unite(i.f,i.t)) ans+=i.w; cout<<ans<<endl; return 0; }
cc1plus: error: '::main' must return 'int' a.cc: In member function 'long long int ufind::find(long long int)': a.cc:27:15: warning: control reaches end of non-void function [-Wreturn-type] 27 | else x=f[x];
s464888398
p03684
C++
#include <iostream> #include <vector> #include <queue> #include <tuple> using namespace std; using ll = long long; const int MAX = 1e5+1; ll G[MAX][MAX]; int N; ll prim(){ ll ans = 0ll; vector<bool> used(N,false); priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > Q; Q.push(make_pair(0,0)); while(!Q.empty()){ int u; ll cost_u; tie(cost_u, u) = Q.top(); Q.pop(); if(used[u]) continue; used[u] = true; ans += cost_u; for(int j=0;j<N;j++){ Q.push(make_pair(G[u][j], j)); } } return ans; } int main(){ cin >> N; vector<pair<int,int> > towns(N); int x,y; for(int i=0;i<N;i++){ scanf("%d%d", &x,&y); towns[i] = make_pair(x,y); } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ ll cost = min(abs(towns[i].first - towns[j].first), abs(towns[i].second-towns[j].second)); G[i][j] = cost; } } cout << prim() << endl; return 0; }
/tmp/cc5UKB2c.o: in function `prim()': a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o /tmp/cc5UKB2c.o: in function `main': a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o a.cc:(.text+0x2d1): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o a.cc:(.text+0x364): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o collect2: error: ld returned 1 exit status
s530558300
p03684
C++
#include <iostream> #include <vector> #include <queue> #include <tuple> #include <cstdio> #include <cstdlib> using namespace std; using ll = long long; const int MAX = 1e5+1; ll G[MAX][MAX]; int N; ll prim(){ ll ans = 0ll; vector<bool> used(N,false); priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > Q; Q.push(make_pair(0,0)); while(!Q.empty()){ int u; ll cost_u; tie(cost_u, u) = Q.top(); Q.pop(); if(used[u]) continue; used[u] = true; ans += cost_u; for(int j=0;j<N;j++){ Q.push(make_pair(G[u][j], j)); } } return ans; } int main(){ cin >> N; vector<pair<int,int> > towns(N); int x,y; for(int i=0;i<N;i++){ scanf("%d%d", &x,&y); towns[i] = make_pair(x,y); } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ ll cost = min(abs(towns[i].first - towns[j].first), abs(towns[i].second-towns[j].second)); G[i][j] = cost; } } cout << prim() << endl; return 0; }
/tmp/cckzbRIK.o: in function `prim()': a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o /tmp/cckzbRIK.o: in function `main': a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o a.cc:(.text+0x2d1): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o a.cc:(.text+0x364): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o collect2: error: ld returned 1 exit status
s085198684
p03684
C++
/************************************************* ************************************************* ************************************************* *** _________________ | | | /*** *** | | | | / *** *** | | | | / *** *** | | | | / *** *** | | | | / *** *** | |____________| |/ en *** *** | | | |\ *** *** | | | | \ *** *** _____ | | | | \ *** *** | | | | | \ *** *** \ / | | | \ *** *** \___/ | | | \*** ************************************************* *************Written by: JiangHaoKai************* *************************************************/ //#include <bits/stdc++.h> #include <cassert> #include <cctype> #include <cerrno> #include <cfloat> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <string> #include <typeinfo> #include <valarray> #include <vector> #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <unordered_map> #include <unordered_set> //#include <windows.h> using namespace std; typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; typedef float fl; typedef double ld; typedef pair<int,int> pii; #define ui(n) ((unsigned int)(n)) #define ll(n) ((long long)(n)) #define ull(n) ((unsigned long long)(n)) #define fl(n) ((float)(n)) #define ld(n) ((double)(n)) #define char(n) ((char)(n)) #define Bool(n) ((bool)(n)) #define fixpoint(n) fixed<<setprecision(n) const int INF=1e9+7; const ll LINF=1e18; #define PI 3.1415926535897932384626433832795028841971 #define MP make_pair #define MT make_tuple #define All(a) (a).begin(),(a).end() #define pall(a) (a).rbegin(),(a).rend() #define mod 1000000007 #define sz(a) ((int)(a).size()) #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define repa(i,a,n) for(int i=a;i<n;i++) #define repd(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,a,n,step) for(int i=a;i<n;i+=step) #define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++) #define repV(i,v) for(auto i:v) #define repE(i,v) for(auto &i:v) #define MS(x,y) memset(x,y,sizeof(x)) #define sqr(x) ((x)*(x)) #define filein(x) freopen(x,"r",stdin) #define fileout(x) freopen(x,"w",stdout) #define fileout2(filename,name) ofstream name(filename,ios::out) #define filein2(filename,name) ifstream name(filename,ios::in) #define file(filename,name) fstream name(filename,ios::in|ios::out) #define Pause system("pause") #define Cls system("cls") #define fs first #define sc second #define PC(x) putchar(x) #define GC(x) x=getchar() #define Endl PC('\n') inline int READ() { int X=0,w=0;char ch=0;while(!isdigit(ch)){w|=ch=='-';ch=getchar();}while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); return w?-X:X; } inline void WRITE(int x){if(x<0)putchar('-'),x=-x;if(x>9)WRITE(x/10);putchar(x%10+'0');} inline void WRITEend(int x){WRITE(x);exit(0);} inline ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} inline ll gcdll(ll a,ll b){return b?gcdll(b,a%b):a;} inline string itoa(ll a){string res="";while(a>0)res+=(a%10+'0'),a/=10;reverse(All(res));return res==""?"0":res;} inline ll atoi(string s){ll res=0;repV(i,s)res=res*10+i-'0';return res;} const int dx[]={0,1,0,-1,1,-1,-1,1}; const int dy[]={1,0,-1,0,-1,-1,1,1}; /**************************************************************Begin***************************************************************/ int n=READ(),px[100010],py[100010],par[100010]; ll ans; pair<int,int> sx[100010],sy[100010]; set<pair<int,pair<int,int> > > s; inline int FIND(int x) { return x==par[x]?x:par[x]=FIND(par[x]); } inline unite(int u,int v) { u=FIND(u); v=FIND(v); if(u==v) return 0; par[u]=v; return 1; } inline int dist(int x,int y) { return min(abs(px[x]-px[y]),abs(py[x]-py[y])); } int main() { rep(i,n) { px[i]=READ();py[i]=READ(); par[i]=i; sx[i]=MP(px[i],i); sy[i]=MP(py[i],i); } sort(sx,sx+n); sort(sy,sy+n); rep(i,n) s.insert(MP(dist(sx[i].sc,sx[i+1].sc),MP(sx[i].sc,sx[i+1].sc))), s.insert(MP(dist(sy[i].sc,sy[i+1].sc),MP(sy[i].sc,sy[i+1].sc))); while(s.size()) { pair<int,pair<int,int> > x=*(s.begin());s.erase(x); int u=x.sc.fs,v=x.sc.sc; ans+=ll(unite(u,v)*dist(u,v)); } printf("%lld",ans); return 0; } /***************************************************************End****************************************************************/
a.cc:159:8: error: ISO C++ forbids declaration of 'unite' with no type [-fpermissive] 159 | inline unite(int u,int v) | ^~~~~
s193810605
p03684
C++
#include <bits/stdc++.h> using namespace std; long long ans; int n,fa[100003],r[100003]; pair<int,int> a[100003],x[100003],y[100003]; priority_queue <pair<int,pair<int,int> > > q; int find_fa(int x){ if(fa[x]==x) return x; return fa[x]=find_fa(fa[x]); } void uni(int x,int y){ x=find_fa(x); y=find_fa(y); if (r[x]<r[y]) fa[x]=y; else{ fa[y]=x; if(r[x]==r[y]) r[x]++; } } int main(){ cin>>n; for(int i=0;i<n;i++) fa[i]=i; for(int i=0;i<n;i++){ cin>>a[i].fi>>a[i].second; x[i]={a[i].fi,i}; y[i]={a[i].second,i}; } sort(x,x+n); sort(y,y+n); for(int i=0;i<n-1;i++){ q.push({-(x[i+1].fi-x[i].fi),{x[i].second,x[i+1].second}}); q.push({-(y[i+1].fi-y[i].fi),{y[i].second,y[i+1].second}}); } while(q.size()){ int c=-q.top().fi,p1=q.top().second.fi,p2=q.top().second.second; if(find_fa(p1)!=find_fa(p2)){ uni(p1,p2); ans+=c; } q.pop(); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:24:27: error: 'struct std::pair<int, int>' has no member named 'fi' 24 | cin>>a[i].fi>>a[i].second; | ^~ a.cc:25:28: error: 'struct std::pair<int, int>' has no member named 'fi' 25 | x[i]={a[i].fi,i}; | ^~ a.cc:25:32: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and '<brace-enclosed initializer list>') 25 | x[i]={a[i].fi,i}; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = int; _T2 = int]' 946 | operator=(const pair<_U1, _U2>& __p) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:946:9: note: template argument deduction/substitution failed: a.cc:25:32: note: couldn't deduce template parameter '_U1' 25 | x[i]={a[i].fi,i}; | ^ /usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = int; _T2 = int]' 957 | operator=(pair<_U1, _U2>&& __p) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:957:9: note: template argument deduction/substitution failed: a.cc:25:32: note: couldn't deduce template parameter '_U1' 25 | x[i]={a[i].fi,i}; | ^ /usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<int, int>&]' 921 | operator=(__conditional_t<__and_<is_copy_assignable<_T1>, | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:923:65: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::__conditional_t<true, const std::pair<int, int>&, const std::__nonesuch&>' {aka 'const std::pair<int, int>&'} 921 | operator=(__conditional_t<__and_<is_copy_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 922 | is_copy_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 923 | const pair&, const __nonesuch&> __p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<int, int>&&]' 931 | operator=(__conditional_t<__and_<is_move_assignable<_T1>, | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:933:55: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::__conditional_t<true, std::pair<int, int>&&, std::__nonesuch&&>' {aka 'std::pair<int, int>&&'} 931 | operator=(__conditional_t<__and_<is_move_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 932 | is_move_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 933 | pair&&, __nonesuch&&> __p) | ~~~~~~~~~~~~~~~~~~~~~~^~~ a.cc:31:34: error: 'struct std::pair<int, int>' has no member named 'fi' 31 | q.push({-(x[i+1].fi-x[i].fi),{x[i].second,x[i+1].second}}); | ^~ a.cc:31:42: error: 'struct std::pair<int, int>' has no member named 'fi' 31 | q.push({-(x[i+1].fi-x[i].fi),{x[i].second,x[i+1].second}}); | ^~ a.cc:31:23: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)' 31 | q.push({-(x[i+1].fi-x[i].fi),{x[i].second,x[i+1].second}}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157: /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'} 736 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:32:34: error: 'struct std::pair<int, int>' has no member named 'fi' 32 | q.push({-(y[i+1].fi-y[i].fi),{y[i].second,y[i+1].second}}); | ^~ a.cc:32:42: error: 'struct std::pair<int, int>' has no member named 'fi' 32 | q.push({-(y[i+1].fi-y[i].fi),{y[i].second,y[i+1].second}}); | ^~ a.cc:32:23: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)' 32 | q.push({-(y[i+1].fi-y[i].fi),{y[i].second,y[i+1].second}}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'} 736 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:35:32: error: 'const __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, std::pair<int, int> > >, std::pair<int, std::pair<int, int> > >::value_type' {aka 'const struct std::pair<int, std::pair<int, int> >'} has no member named 'fi' 35 | int c=-q.top().fi,p1=q.top().second.fi,p2=q.top().second.second; | ^~ a.cc:36:28: error: 'p1' was not declared in this scope; did you mean 'y1'? 36 | if(find_fa(p1)!=find_fa(p2)){ | ^~ | y1 a.cc:36:41: error: 'p2' was not declared in this scope 36 | if(find_fa(p1)!=find_fa(p2)){ | ^~
s086711520
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long int LLI; typedef pair<int, int> Pair; typedef pair<int, Pair> Edge; int N; LLI ans; int par[114514]; int rank[114514]; vector<Pair> xs; vector<Pair> ys; vector<Edge> es; int find(int v) { if (par[v] == v) return v; return par[v] = find(par[v]); } int same(int u, int v) { return find(u) == find(v); } void unite(int u, int v) { u = find(u); v = find(v); if (u == v) return; if (rank[u] > rank[v]) par[v] = u; else { par[u] = v; if (rank[u] == rank[v]) rank[v]++; } } int main() { scanf("%d", &N); for (int i=0; i<N; i++) { int x, y; scanf("%d%d", &x, &y); xs.emplace_back(Pair(x, i)); ys.emplace_back(Pair(y, i)); par[i] = i; } sort(xs.begin(), xs.end()); sort(ys.begin(), ys.end()); for (int i=1; i<N; i++) { es.emplace_back(Edge(xs[i].first-xs[i-1].first, Pair(xs[i-1].second, xs[i].second))); es.emplace_back(Edge(ys[i].first-ys[i-1].first, Pair(ys[i-1].second, ys[i].second))); } sort(es.begin(), es.end()); for (auto &e : es) { int u, v; tie(u, v) = e.second; if (same(u, v)) continue; unite(u, v); ans += e.first; } printf("%lld\n", ans); }
a.cc: In function 'void unite(int, int)': a.cc:29:7: error: reference to 'rank' is ambiguous 29 | if (rank[u] > rank[v]) par[v] = u; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [114514]' 11 | int rank[114514]; | ^~~~ a.cc:29:17: error: reference to 'rank' is ambiguous 29 | if (rank[u] > rank[v]) par[v] = u; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [114514]' 11 | int rank[114514]; | ^~~~ a.cc:32:9: error: reference to 'rank' is ambiguous 32 | if (rank[u] == rank[v]) rank[v]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [114514]' 11 | int rank[114514]; | ^~~~ a.cc:32:20: error: reference to 'rank' is ambiguous 32 | if (rank[u] == rank[v]) rank[v]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [114514]' 11 | int rank[114514]; | ^~~~ a.cc:32:29: error: reference to 'rank' is ambiguous 32 | if (rank[u] == rank[v]) rank[v]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [114514]' 11 | int rank[114514]; | ^~~~
s709113589
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAX 100001 int x[MAX], y[MAX]; int main(void) { int N, xmin = int(1e9), xmax = 0, ymin = int(1e9), ymax = 0; scanf("%d", &N); for(int i = 0; i < N; i++) { scanf("%d%d", x+i, y+i); xmin = min(xmin, x[i]); xmax = max(xmax, x[i]); ymin = min(ymin, y[i]); ymax = man(ymax, y[i]); } return !printf("%d\n", min(xmax - xmin, ymax - ymin)); }
a.cc: In function 'int main()': a.cc:17:16: error: 'man' was not declared in this scope; did you mean 'tan'? 17 | ymax = man(ymax, y[i]); | ^~~ | tan
s746031122
p03684
C++
#include <iostream> #include <vector> #include <queue> #include <utility> using namespace std; const int MAX = 100000; const int WHITE = 0; const int BLACK = 1; const int GRAY = 2; const int INFTY = (int) 1 << 21; typedef pair<int,int> t_pi; int n; int list[MAX][MAX]; int d[MAX], color[MAX], p[MAX]; t_pi pos[MAX]; int cost_func(t_pi a, t_pi b){ int A = abs(a.first-b.first); int B = abs(a.second-b.second); return min(A,B); } int prim(){ for(int i=0;i<n;i++){ color[i] = WHITE; p[i] = -1; d[i] = INFTY; } d[0] = 0; while(true){ int mincost = INFTY; int u = -1; for(int i=0;i<n;i++){ if(color[i] != BLACK && d[i] < mincost){ mincost = d[i]; u = i; } } if(u == -1) break; color[u] = BLACK; for(int v=0;v<n;v++){ if(color[v] != BLACK ){ if(d[v] > list[u][v]){ d[v] = list[u][v]; p[v] = u; color[v] = GRAY; } } } } int total = 0; for(int i=0;i<n;i++){ if(p[i] != -1){ total += list[i][p[i]]; } } return total; } int main(void){ cin >> n; int x, y; for(int i=0;i<n;i++){ cin >> x >> y; pos[i] = make_pair(x,y); } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ int tmp = cost_func(pos[i],pos[j]); list[i][j] = tmp; } } cout << prim() << endl; return 0; }
/tmp/ccvgGfCX.o: in function `prim()': a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x83): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o a.cc:(.text+0x20b): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s586982734
p03684
C++
#include<bits/stdc++.h> using namespace std; #define MAX_N 300000 #define MAX_E 300000 typedef pair<int,int> P; int par[MAX_N]; int rank[MAX_N]; void init(int n){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x)return x; else return par[x]=find(par[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(rank[x]<rank[y])par[x]=y; else { par[y]=x; if(rank[x]==rank[y])rank[x]++; } } bool same(int x,int y){ return find(x)==find(y); } struct edge{int u,v,cost;}; bool comp(const edge& e1,const edge e2){ return e1.cost < e2.cost; } edge es[MAX_E]; int V,E; //頂点数、辺数 int kruskal(){ sort(es,es+E,comp); init(V); int res=0; for(int i=0;i<E;i++){ edge e=es[i]; if(!same(e.u,e.v)){ unite(e.u,e.v); res+=e.cost; } } return res; } int main(){ cin>>V; vector<P> vx,vy; for(int i=0;i<V;i++){ int x,y; cin>>x>>y; vx.push_back(P(x,i)); vy.push_back(P(y,i)); } sort(vx.begin(),vx.end()); sort(vy.begin(),vy.end()); int cnt=0; for(int i=1;i<vx.size();i++){ int u=vx[i-1].second; int v=vx[i].second; int cost=vx[i].first-vx[i-1].first; es[cnt++]=(edge){u,v,cost}; } for(int i=1;i<vy.size();i++){ int u=vy[i-1].second; int v=vy[i].second; int cost=vy[i].first-vy[i-1].first; es[cnt++]=(edge){u,v,cost}; } E=cnt; cout<<kruskal()<<endl; return 0; }
a.cc: In function 'void init(int)': a.cc:13:5: error: reference to 'rank' is ambiguous 13 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:25:6: error: reference to 'rank' is ambiguous 25 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~ a.cc:25:14: error: reference to 'rank' is ambiguous 25 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~ a.cc:28:8: error: reference to 'rank' is ambiguous 28 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~ a.cc:28:17: error: reference to 'rank' is ambiguous 28 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~ a.cc:28:25: error: reference to 'rank' is ambiguous 28 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:5: note: 'int rank [300000]' 8 | int rank[MAX_N]; | ^~~~
s391725196
p03684
C++
#include <iostream> #include <vector> #include <map> using namespace std; using ll = long long; struct V { int index; ll x, y; }; struct E { int v, u; ll cost; }; struct UnionFind { vector<int> data; UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; int main() { int N; cin >> N; vector<V> vs; for (int i = 0; i < N; i++) { ll x, y; cin >> x >> y; vs.push_back(V{ i, x, y }); } vector<E> es; sort(vs.begin(), vs.end(), [](const V &a, const V &b) { return a.x < b.x; }); for (int i = 1; i < N; i++) { es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].x - vs[i-1].x }); } sort(vs.begin(), vs.end(), [](const V &a, const V &b) { return a.y < b.y; }); for (int i = 1; i < N; i++) { es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].y - vs[i-1].y }); } sort(es.begin(), es.end(), [](const E &a, const E &b) { return a.cost < b.cost; }); UnionFind uf(N); ll res = 0; for (const auto &e: es) { if (!uf.findSet(e.v, e.u)) { res += e.cost; uf.unionSet(e.v, e.u); } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:3: error: 'sort' was not declared in this scope; did you mean 'short'? 47 | sort(vs.begin(), vs.end(), [](const V &a, const V &b) { | ^~~~ | short
s295876111
p03684
C++
#include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <cstdio> #include <map> #include <stack> #include <queue> #include <set> #include <cstdlib> #include <stack> #include <vector> #define INF 0x3f3f3f3f #define MOD 1000000009 # define FOR(i,a,n) for(register int i=a; i<=n; ++i) # define FDR(i,a,n) for(register int i=a; i>=n; --i) typedef long long ll; using namespace std; struct A { int l; int r; int q; }; A aa[100005]; int d[100005][100005]; int a[100005], b[100005]; int f[100005]; int finds(int x) { return f[x] == x?x:f[x] = finds(f[x]); } int cmp(A a, A b) { return a.q < b.q; } int main() { int n; scanf("%d", &n); FOR(i,1,n) { scanf("%d%d", &a[i], &b[i]); } int ji = 0; FOR(i,1,n) { FOR(j,i+1,n) { aa[ji].l = i; aa[ji].r = j; aa[ji++].q = min(abs(a[i]-a[j]), abs(b[i]-b[j])); } } sort(aa, aa+ji, cmp); FOR(i,1,n) f[i] = i; int ans = 0; for(int i = 0; i < ji; i++) { int x = finds(aa[i].l); int y = finds(aa[i].r); if(x != y) { f[x] = y; ans += aa[i].q; } } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:42:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 42 | FOR(i,1,n) | ^ a.cc:15:38: note: in definition of macro 'FOR' 15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i) | ^ a.cc:47:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 47 | FOR(i,1,n) | ^ a.cc:15:38: note: in definition of macro 'FOR' 15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i) | ^ a.cc:49:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 49 | FOR(j,i+1,n) | ^ a.cc:15:38: note: in definition of macro 'FOR' 15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i) | ^ a.cc:57:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 57 | FOR(i,1,n) | ^ a.cc:15:38: note: in definition of macro 'FOR' 15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i) | ^ /tmp/ccdpg6AQ.o: in function `finds(int)': a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o /tmp/ccdpg6AQ.o: in function `main': a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x1d7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o a.cc:(.text+0x291): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s466468155
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<iomanip> #include<algorithm> using namespace std; #define inf 1<<29 #define nu 1000005 #define maxnum 100005 #define num 30 int n; struct Md { int v,u,flag; }M[maxnum],C[maxnum]; struct Node { int x,y,z; }dis[nu]; bool cmp(Md a,Md b){ return a.v<b.v; } bool cmp0(Md a,Md b){ return a.u<b.u; } bool cmp1(Node a,Node b){ return a.z<b.z; } int book[maxnum]; void init() { for(int i=1;i<=n;i++) book[i]=i; } int getx(int x) { if(book[x]!=x) book[x]=getx(book[x]); return book[x]; } void mergexy(int x,int y) { book[y]=x; } void change(){ for(int i=1;i<=n;i++) { C[i].v=M[i].v; C[i].u=M[i].u; C[i].flag=M[i].flag; } } int main() { scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&M[i].v,&M[i].u); M[i].flag=i; } /* int t=unique(M+1,M+n)-M; for(int i=1;i<=t;i++) cout<<M[i].v<<" "<<M[i].u<<endl; n=t; change();*/ int fl=0; sort(C+1,C+n+1,cmp); for(int i=2;i<=n;i++) { dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u))); } change(); sort(C+1,C+n+1,cmp0); for(int i=2;i<=n;i++) { dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u))); } sort(dis+1,dis+flag+1,cmp1); /* cout<<flag<<endl; for(int i=1;i<=flag;i++) cout<<dis[i].z<<endl;*/ init(); int number=0; int sum=0; for(int i=1;i<=flag;i++) { int p=getx(dis[i].x),q=getx(dis[i].y); if(p!=q){ mergexy(p,q); number++; sum+=dis[i].z; } if(number==n) break; } cout<<sum<<endl; return 0; }
a.cc: In function 'int main()': a.cc:82:20: error: 'flag' was not declared in this scope; did you mean 'fl'? 82 | sort(dis+1,dis+flag+1,cmp1); | ^~~~ | fl
s526253464
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<iomanip> #include<algorithm> using namespace std; #define inf 1<<29 #define nu 1000005 #define maxnum 100005 #define num 30 int n; struct Md { int v,u,flag; }M[maxnum],C[maxnum]; struct Node { int x,y,z; }dis[nu]; bool cmp(Md a,Md b){ return a.v<b.v; } bool cmp0(Md a,Md b){ return a.u<b.u; } bool cmp1(Node a,Node b){ return a.z<b.z; } int book[maxnum]; void init() { for(int i=1;i<=n;i++) book[i]=i; } int getx(int x) { if(book[x]!=x) book[x]=getx(book[x]); return book[x]; } void mergexy(int x,int y) { book[y]=x; } void change(){ for(int i=1;i<=n;i++) { C[i].v=M[i].v; C[i].u=M[i].u; C[i].flag=M[i].flag; } } int main() { scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&M[i].v,&M[i].u); M[i].flag=i; } int t=unique(M+1,M+n)-M; /*for(int i=1;i<=t;i++) cout<<M[i].v<<" "<<M[i].u<<endl;*/ n=t; change(); int fl=0; sort(C+1,C+n+1,cmp); for(int i=2;i<n;i++) { dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u))); } for change(); sort(C+1,C+n+1,cmp0); for(int i=2;i<n;i++) { dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u))); } sort(dis+1,dis+flag+1,cmp1); /* cout<<flag<<endl; for(int i=1;i<=flag;i++) cout<<dis[i].z<<endl;*/ init(); int number=0; int sum=0; for(int i=1;i<=flag;i++) { int p=getx(dis[i].x),q=getx(dis[i].y); if(p!=q){ mergexy(p,q); number++; sum+=dis[i].z; } if(number==n) break; } cout<<sum<<endl; return 0; }
a.cc: In function 'int main()': a.cc:77:7: error: expected '(' before 'change' 77 | change(); | ^~~~~~ | ( a.cc:78:11: error: could not convert 'std::sort<Md*, bool (*)(Md, Md)>((((Md*)(& C)) + 12), (((Md*)(& C)) + ((((sizetype)n) + 1) * 12)), cmp0)' from 'void' to 'bool' 78 | sort(C+1,C+n+1,cmp0); | ~~~~^~~~~~~~~~~~~~~~ | | | void a.cc:79:7: error: expected primary-expression before 'for' 79 | for(int i=2;i<n;i++) | ^~~ a.cc:78:28: error: expected ')' before 'for' 78 | sort(C+1,C+n+1,cmp0); | ^ | ) 79 | for(int i=2;i<n;i++) | ~~~ a.cc:77:7: note: to match this '(' 77 | change(); | ^~~~~~ a.cc:83:20: error: 'flag' was not declared in this scope; did you mean 'fl'? 83 | sort(dis+1,dis+flag+1,cmp1); | ^~~~ | fl In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = Md*; _Iterator2 = Md*]': /usr/include/c++/14/bits/stl_algo.h:869:20: required from '_ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = Md*; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]' 869 | if (!__binary_pred(__dest, __first)) | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:900:27: required from '_FIter std::unique(_FIter, _FIter) [with _FIter = Md*]' 900 | return std::__unique(__first, __last, | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 901 | __gnu_cxx::__ops::__iter_equal_to_iter()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:65:17: required from here 65 | int t=unique(M+1,M+n)-M; | ~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:117:23: error: no match for 'operator==' (operand types are 'Md' and 'Md') 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1208:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1208 | operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1208:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:117:23: note: 'Md' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1216:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1216 | operator==(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1216:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:117:23: note: 'Md' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~
s209485122
p03684
C++
#include "bits/stdc++.h" #include <unordered_set> using namespace std; #define DEBUG(x) cout<<#x<<": "<<x<<endl; #define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector< vector<int> > #define vll vector< vector<ll> > #define vs vector<string> #define pii pair<int,int> #define pis pair<int,string> #define psi pair<string,int> const int inf = 1000000001; const ll INF = 1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl; int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 }; #define N 100010 int n; //i‚ÆM[i].second‚ðM[i].first‚ł‚Ȃ® vector< vector<pii> > M(N, vector<pii>()); vector<bool> used(N, false); vector< pair<pii, int> > r(n); vi mincost(N, inf); bool cmp1(pair<pii, int> a, pair<pii, int> b) { if (a.first.second < b.first.second) { return true; } else if (a.first.second > b.first.second) { return false; } else { if (a.first.first < b.first.first) { return true; } else if (a.first.first > b.first.first) { return false; } else { if (a.second < b.second) { return true; } else { return false; } } } } void init() { cin >> n; for (int i = 0; i < n; i++) { cin >> r[i].first.first >> r[i].first.second; r[i].first.first--; r[i].first.second--; r[i].second = i; } sort(r.begin(), r.end()); for (i = 0; i < n - 1; i++) { int x1 = r[i].first.first, y1 = r[i].first.second; int x2 = r[i + 1].first.first, y2 = r[i + 1].first.second; int r1 = r[i].second, r2 = r[i + 1].second; M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); M[r2].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r1)); } sort(r.begin(), r.end(), cmp1); for (i = 0; i < n - 1; i++) { int x1 = r[i].first.first, y1 = r[i].first.second; int x2 = r[i + 1].first.first, y2 = r[i + 1].first.second; int r1 = r[i].second, r2 = r[i + 1].second; M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); M[r2].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r1)); } } void prim(int s) { priority_queue<pii, vector<pii>, greater<pii> > pq; int used_cnt = 0; mincost[s] = 0; pq.push(make_pair(0, s)); int i; while (used_cnt < n) { int u; pii f; while (true) { f = pq.top(); pq.pop(); u = f.second; if (!used[u]) { break; } } mincost[u] = f.first; for (i = 0; i < M[u].size(); i++) { int v = M[u][i].second; int c = M[u][i].first; pq.push(make_pair(c, v)); } used[u] = true; used_cnt++; } } void ans() { ll sum = 0; for (int i = 0; i < n; i++) { sum += mincost[i]; } cout << sum << endl; } void solve() { init(); prim(0); ans(); return; } int main() { solve(); } /* 3 1 5 3 9 7 8 6 8 3 4 9 12 19 18 1 13 5 7 6 */
a.cc: In function 'void init()': a.cc:69:8: error: 'i' was not declared in this scope 69 | for (i = 0; i < n - 1; i++) { | ^ a.cc:73:53: error: 'y2' was not declared in this scope; did you mean 'x2'? 73 | M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); | ^~ | x2 a.cc:73:64: error: 'r2' was not declared in this scope; did you mean 'r1'? 73 | M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); | ^~ | r1 a.cc:77:8: error: 'i' was not declared in this scope 77 | for (i = 0; i < n - 1; i++) { | ^ a.cc:81:53: error: 'y2' was not declared in this scope; did you mean 'x2'? 81 | M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); | ^~ | x2 a.cc:81:64: error: 'r2' was not declared in this scope; did you mean 'r1'? 81 | M[r1].push_back(make_pair(min(abs(x2 - x1), abs(y2 - y1)), r2)); | ^~ | r1
s016534636
p03684
C++
#include <iostream> #include <vector> #include <map> #include <queue> using namespace std; typedef pair< int, int > iP; typedef pair< iP, int > iiP; #define PREV(i, s) ((i - 1 + s) % s) #define NEXT(i, s) ((i + 1) % s) vector< iP > pp; int prim(vector< vector< int > > &g) { int ret = 0; int s = g.size(); priority_queue< iP, vector< iP >, greater< iP > > q; vector< int > v(s + 1, 0); q.push(iP(0, 0)); while(!q.empty()) { iP p = q.top(); q.pop(); if(v[p.second]++) continue; ret += p.first; int now = p.second; for(int i = 0; i < g[now].size(); i++) { q.push(iP(min(abs(pp[now].first - pp[g[now][i]].first), abs(pp[now].second - pp[g[now][i]].second)), g[now][i])); } } return ret; } int main() { int n; vector< iiP > g1, g2; vector< vector< int > > g0; cin >> n; g0.resize(n + 1); pp.resize(n); for(int i = 0; i < n; i++) { int x, y; cin >> x >> y; pp[i] = iP(x, y); g1.push_back(iiP(iP(x, y), i)); g2.push_back(iiP(iP(y, x), i)); } sort(g1.begin(), g1.end()); sort(g2.begin(), g2.end()); for(int i = 0; i < n; i++) { g0[i].push_back(g1[PREV(i, n)].second), g0[i].push_back(g1[NEXT(i, n)].second); g0[i].push_back(g2[PREV(i, n)].second), g0[i].push_back(g2[NEXT(i, n)].second); } cout << prim(g0) << endl; }
a.cc: In function 'int main()': a.cc:48:5: error: 'sort' was not declared in this scope; did you mean 'short'? 48 | sort(g1.begin(), g1.end()); | ^~~~ | short
s510522094
p03684
C
/* cat <<EOF >mistaken-paste */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #define BIG 2000000007 #define MOD 1000000007 typedef unsigned long long ull; typedef signed long long sll; #define N_MAX 200000 #define M_MAX 100000 typedef struct { int a; int b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { ull a; int i; } struct_a; typedef struct { ull cost; int left; int right; } struct_b; const hw vector8[8] = { {-1, -1}, {-1, 0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1, 0}, {+1, +1} }; ull n, m; ull h, w; ull k; sll va, vb, vc, vd, ve, vf; ull a[N_MAX]; // sll a[N_MAX]; ull b[N_MAX]; // sll b[M_MAX]; // char s[N_MAX + 1]; // char t[N_MAX + 1]; // char s[N_MAX][M_MAX + 1]; // ull dp[N_MAX]; // ull dp[N_MAX + 1][N_MAX + 1]; // ull dp[N_MAX][M_MAX + 1]; // hw arr[N_MAX]; // hwll arr[N_MAX]; // hw brr[M_MAX]; struct_a arr[N_MAX * 2]; struct_b brr[N_MAX * 2]; // ull digitdp[102][ 2][ 2]; // pos less carry void swap_adj(ull *a, ull *b){ ull tmp = *b; *b = *a; *a = tmp; return; } ull divide(ull a, ull b){ ull x = MOD - 2; ull ans = 1; while (x) { if (x & 1) ans = (ans * b) % MOD; b = (b * b) % MOD; x /= 2; } return (a * ans) % MOD; } int digits(ull x){ int i = 1; while (x >= 10) { x /= 10; i++; } return i; } ull min(ull x, ull y){ return (x < y) ? x : y; } ull max(ull x, ull y){ return (x > y) ? x : y; } ull gcd(ull x, ull y){ if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow(ull a, ull x){ ull result = 1; while (x) { if (x & 1) { result *= a; result %= MOD; } x /= 2; a = (a * a) % MOD; } return result; } // int nextroute(int arr[]){ // int i = n - 1; // int j, x; // while (arr[i - 1] > arr[i]) i--; // x = n; // for (j = i; j < n; j++) { // if (arr[j] < arr[i - 1]) continue; // if (x == n || arr[x] > arr[j]) x = j; // } // arr[i - 1] ^= arr[x]; // arr[x] ^= arr[i - 1]; // arr[i - 1] ^= arr[x]; // qsort(&arr[i], n - i, sizeof(int), comp); // return 0; // } int nibutan_target(ull target){ ull maxdist = (target * (target + 1) / 2); // 時刻targetまでに到着できる距離は[-maxdist, maxdist] return (n <= maxdist); } int targetdig(ull x, int index /* 1-indexed */){ // static...? int posmax = digits(x); if (posmax < index) return -1; while (posmax > index) { posmax--; x /= 10; } return x % 10; } int intcomp(const void *left, const void *right){ if ((*(int*)left) < (*(int*)right)) { return -1; } else if ((*(int*)left) > (*(int*)right)) { return +1; } else { return 0; } } int ullcomp(const void *left, const void *right){ if ((*(ull*)left) < (*(ull*)right)) { return -1; } else if ((*(ull*)left) > (*(ull*)right)) { return +1; } else { return 0; } } int sllcomp(const void *left, const void *right){ if ((*(sll*)left) < (*(sll*)right)) { return -1; } else if ((*(sll*)left) > (*(sll*)right)) { return +1; } else { return 0; } } int hwAcomp(const void *left, const void *right){ return intcomp(&(((hw*)left)->a), &(((hw*)right)->a)); } int hwBcomp(const void *left, const void *right){ return intcomp(&(((hw*)left)->b), &(((hw*)right)->b)); } int hwABcomp(const void *left, const void *right){ int x = hwAcomp(left, right); if (x) return x; return hwBcomp(left, right); } int hwllAcomp(const void *left, const void *right){ return sllcomp(&(((hw*)left)->a), &(((hw*)right)->a)); } int hwllBcomp(const void *left, const void *right){ return sllcomp(&(((hw*)left)->b), &(((hw*)right)->b)); } int hwllABcomp(const void *left, const void *right){ int x = hwllAcomp(left, right); if (x) return x; return hwllBcomp(left, right); } int strAcomp(const struct_a *left, const struct_a *right){ return ullcomp(&(left->a), &(right->a)); } int strBcomp(const struct_b *left, const struct_b *right){ return ullcomp(&(left->cost), &(right->cost)); } int bitlet(char c){ return (1 << (c - 'a')); } ull seg[262144]; ull baseIndex; int initSeg(ull a[], int num) { int i; baseIndex = 1; while (baseIndex < num) baseIndex *= 2; for (i = 0; i < baseIndex; i++) { seg[baseIndex + i] = (i < num ? a[i] : 0); } for (i = baseIndex - 1; i >= 1; i--) { seg[i] = seg[i * 2] + seg[i * 2 + 1]; } } ull plainAnswerSeg(int num) { ull lookIndex = baseIndex; ull result = 0; while (num) { if (num % 2 == 1) { result += seg[lookIndex + num - 1]; } lookIndex /= 2; num /= 2; } return result; } int parent[N_MAX]; int rank[N_MAX]; void uf_init(int n){ int i; for (i = 0; i < n; i++) { parent[i] = i; rank[i] = 0; } } void uf_find(int x){ if (parent[x] == x) { return x; } else { return parent[x] = uf_find(parent[x]); } } int uf_unite(int x, int y){ x = uf_find(x); y = uf_find(y); if (x == y) return 1; if (rank[x] < rank[y]) { parent[x] = y; } else { parent[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool uf_same(int x, int y){ return uf_find(x) == uf_find(y); } ull gapAnswerSeg(int start, int end){ if (start > end) return gapAnswerSeg(end, start); return plainAnswerSeg(end) - plainAnswerSeg(start - 1); } ull ulldiff(ull a, ull b){ if (a >= b) { return a - b; } else { return b - a; } } ull ullkaijo(ull a){ ull i; ull result = 1; for (i = 1; i <= a; i++) { result *= i; result %= MOD; } return result; } ull solve(){ int i, j, ki; for (i = 0; i < n; i++) { arr[i].a = a[i]; arr[i].i = i; } qsort(arr, n, sizeof(struct_a), strAcomp); for (i = 0; i < n - 1; i++) { brr[i].cost = arr[i + 1].a - arr[i].a; brr[i].left = arr[i].i; brr[i].right = arr[i + 1].i; } for (i = 0; i < n; i++) { arr[i].a = b[i]; arr[i].i = i; } qsort(arr, n, sizeof(struct_a), strAcomp); for (i = 0; i < n - 1; i++) { brr[i + (n - 1)].cost = arr[i + 1].a - arr[i].a; brr[i + (n - 1)].left = arr[i].i; brr[i + (n - 1)].right = arr[i + 1].i; } qsort(brr, (n - 1) * 2, sizeof(struct_b), strBcomp); uf_init(n); int path = 1; i = 0; ull result = 0; while (path < n) { struct_b brri = brr[i]; if (!uf_same(brri.left, brri.right)) { uf_unite(brri.left, brri.right); path++; result += brri.cost; } } printf("%llu\n", result); return 0; } int main(void){ int i, j; int x, y; scanf("%llu", &n, &m); for (i = 0; i < n; i++) { scanf("%llu%llu", &a[i], &b[i]); } solve(); return 0; }
main.c: In function 'uf_find': main.c:290:24: error: 'return' with a value, in function returning void [-Wreturn-mismatch] 290 | return x; | ^ main.c:288:6: note: declared here 288 | void uf_find(int x){ | ^~~~~~~ main.c:292:34: error: void value not ignored as it ought to be 292 | return parent[x] = uf_find(parent[x]); | ^ main.c:292:24: error: 'return' with a value, in function returning void [-Wreturn-mismatch] 292 | return parent[x] = uf_find(parent[x]); | ^~~~~~ main.c:288:6: note: declared here 288 | void uf_find(int x){ | ^~~~~~~ main.c: In function 'uf_unite': main.c:297:11: error: void value not ignored as it ought to be 297 | x = uf_find(x); | ^ main.c:298:11: error: void value not ignored as it ought to be 298 | y = uf_find(y); | ^ main.c: In function 'uf_same': main.c:310:16: error: void value not ignored as it ought to be 310 | return uf_find(x) == uf_find(y); | ^~~~~~~~~~ main.c:310:30: error: void value not ignored as it ought to be 310 | return uf_find(x) == uf_find(y); | ^~~~~~~~~~ main.c: In function 'solve': main.c:344:41: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 344 | qsort(arr, n, sizeof(struct_a), strAcomp); | ^~~~~~~~ | | | int (*)(const struct_a *, const struct_a *) In file included from main.c:5: /usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'int (*)(const struct_a *, const struct_a *)' 971 | __compar_fn_t __compar) __nonnull ((1, 4)); | ~~~~~~~~~~~~~~^~~~~~~~ main.c:355:41: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 355 | qsort(arr, n, sizeof(struct_a), strAcomp); | ^~~~~~~~ | | | int (*)(const struct_a *, const struct_a *) /usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'int (*)(const struct_a *, const struct_a *)' 971 | __compar_fn_t __compar) __nonnull ((1, 4)); | ~~~~~~~~~~~~~~^~~~~~~~ main.c:362:51: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 362 | qsort(brr, (n - 1) * 2, sizeof(struct_b), strBcomp); | ^~~~~~~~ | | | int (*)(const struct_b *, const struct_b *) /usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'int (*)(const struct_b *, const struct_b *)' 971 | __compar_fn_t __compar) __nonnull ((1, 4)); | ~~~~~~~~~~~~~~^~~~~~~~
s246432648
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; int n; P x[100001]; P y[100001]; int p[100001]; int rank[100001]; void init(int n) { for(int i = 0; i < n; i++) { p[i] = i; rank[i] = 0; } } int Find(int x) { return p[x] == x ? x : (p[x] = Find(p[x])); } void Union(int x, int y) { int a = Find(x); int b = Find(y); if(a == b) return; if(rank[x] > rank[y]) p[y] = x; else { p[x] = y; if(rank[x] == rank[y]) rank[x]++; } } struct edge{ int cost,from,to; edge(int c, int f, int t) : cost(c),from(f),to(t) {} }; bool operator < (const edge& x, const edge& y) { return x.cost < y.cost; } vector<edge> e; int main() { cin >> n; init(n); for(int i = 0; i < n; i++) { int xx, yy; cin >> xx >> yy; x[i] = P(xx,i); y[i] = P(yy,i); } sort(x,x+n); sort(y,y+n); for(int i = 1; i < n; i++) { e.push_back(edge(abs(x[i].first - x[i-1].first),x[i-1].second,x[i].second)); e.push_back(edge(abs(x[i].first - x[i-1].first),x[i].second,x[i-1].second)); e.push_back(edge(abs(y[i].first - y[i-1].first),y[i-1].second,y[i].second)); e.push_back(edge(abs(y[i].first - y[i-1].first),y[i].second,y[i-1].second)); } sort(e.begin(),e.end()); /*for(int i = 0; i < e.size();i++) { cout << e[i].cost <<" "<<e[i].from<<" "<<e[i].to<<endl; }*/ long long int ans = 0; for(int i = 0; i < e.size(); i++) { if(Find(e[i].from) != Find(e[i].to)) { //cout << Find(e[i].from) <<" "<<Find(e[i].to)<<endl; // cout << e[i].cost <<" "<<e[i].from<<" "<<e[i].to<< endl; ans += e[i].cost; //cout << ans << endl; Union(Find(e[i].from),Find(e[i].to)); } } cout << ans << endl; }
a.cc: In function 'void init(int)': a.cc:15:5: error: reference to 'rank' is ambiguous 15 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:27:6: error: reference to 'rank' is ambiguous 27 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:27:16: error: reference to 'rank' is ambiguous 27 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:8: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:19: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:28: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~
s603102471
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; int n; P x[100001]; P y[100001]; int p[100001]; int rank[100001]; void init(int n) { for(int i = 0; i < n; i++) { p[i] = i; rank[i] = 0; } } int Find(int x) { return p[x] == x ? x : (p[x] = Find(p[x])); } void Union(int x, int y) { int a = Find(x); int b = Find(y); if(a == b) return; if(rank[x] > rank[y]) p[y] = x; else { p[x] = y; if(rank[x] == rank[y]) rank[x]++; } } struct edge{ int cost,from,to; edge(int c, int f, int t) : cost(c),from(f),to(t) {} bool operator < (const edge& x) { return cost < x.cost; } }; vector<edge> e; int main() { cin >> n; init(n); for(int i = 0; i < n; i++) { int xx, yy; cin >> xx >> yy; x[i] = P(xx,i); y[i] = P(yy,i); } sort(x,x+n); sort(y,y+n); for(int i = 1; i < n; i++) { e.push_back(edge(abs(x[i].first - x[i-1].first),x[i-1].second,x[i].second)); /* e.push_back(edge(abs(x[i].first - x[i-1].first),x[i].second,x[i-1].second)); */ e.push_back(edge(abs(y[i].first - y[i-1].first),y[i-1].second,y[i].second)); // e.push_back(edge(abs(y[i].first - y[i-1].first),y[i].second,y[i-1].second)); } sort(e.begin(),e.end()); /*for(int i = 0; i < e.size();i++) { cout << e[i].cost <<" "<<e[i].from<<" "<<e[i].to<<endl; }*/ long long int ans = 0; for(int i = 0; i < e.size(); i++) { if(Find(e[i].from) != Find(e[i].to)) { //cout << Find(e[i].from) <<" "<<Find(e[i].to)<<endl; // cout << e[i].cost <<" "<<e[i].from<<" "<<e[i].to<< endl; ans += e[i].cost; //cout << ans << endl; Union(e[i].from,e[i].to); } } cout << ans << endl; }
a.cc: In function 'void init(int)': a.cc:15:5: error: reference to 'rank' is ambiguous 15 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:27:6: error: reference to 'rank' is ambiguous 27 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:27:16: error: reference to 'rank' is ambiguous 27 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:8: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:19: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~ a.cc:30:28: error: reference to 'rank' is ambiguous 30 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100001]' 10 | int rank[100001]; | ^~~~
s623112763
p03684
C++
#include <iostream> #include <vector> #include <queue> #define INF 2000000000 using namespace std; int main(){ int n; cin >> n; vector<pair<int,int> > px,py; //adjacent list vector<pair<int,int> > G[n+1]; for(int i=1;i<=n;i++){ int x,y; cin >> x >> y; px.push_back(make_pair(x,i)); py.push_back(make_pair(y,i)); } sort(px.begin(),px.end()); sort(py.begin(),py.end()); for(int i=0;i<n-1;i++){ G[px[i].second].push_back(make_pair(px[i+1].second,px[i+1].first-px[i].first)); G[px[i+1].second].push_back(make_pair(px[i].second,px[i+1].first-px[i].first)); G[py[i].second].push_back(make_pair(py[i+1].second,py[i+1].first-py[i].first)); G[py[i+1].second].push_back(make_pair(py[i].second,py[i+1].first-py[i].first)); } /*for(int i=1;i<=n;i++){ for(int j=0;j<G[i].size();j++){ cout << i << " " << G[i][j].first << " " << G[i][j].second << endl; } }*/ //minimum spanning tree //PQ has make_pair(d[id],id) priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > PQ; int visited[n+1],d[n+1]; for(int i=1;i<=n;i++){ visited[i]=0; d[i]=INF; } d[1]=0; PQ.push(make_pair(0,1)); int sum=0; while(PQ.empty()==false){ int u=PQ.top().second; int u_cost=PQ.top().first; PQ.pop(); if(u_cost>d[u]) continue; visited[u]=1; sum=sum+d[u]; for(int i=0;i<G[u].size();i++){ if(visited[G[u][i].first]==0){ if(G[u][i].second<d[G[u][i].first]){ d[G[u][i].first]=G[u][i].second; PQ.push(make_pair(d[G[u][i].first],G[u][i].first)); } } } } cout << sum << endl; }
a.cc: In function 'int main()': a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(px.begin(),px.end()); | ^~~~ | short
s787415084
p03684
C++
#include <bits/stdc++.h> using namespace std; #define MAX_N 100010 struct point {int id, x, y;}; struct edge {int u, v, w;}; int n; point p[MAX_N]; edge edgeset[2 * MAX_N]; int pa[MAX_N]; int rank[MAX_N]; void init(void) { memset(pa, 0, sizeof(pa)); memset(rank, 0, sizeof(rank)); for (int i = 0; i < n; i++) { pa[i] = i; rank[i] = 0; } } int find(int x) { if (pa[x] == x) return x; else return pa[x] = find(pa[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) pa[x] = y; else { pa[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return (find(x) == find(y)); } int abs(int a) { return a >= 0? a: -a; } bool cmp_x(point a, point b) { return a.x < b.x; } bool cmp_y(point a, point b) { return a.y < b.y; } bool cmp_edge(edge a, edge b) { return a.w <= b.w; } int mst(void) { init(); int res = 0; for (int i = 0; i < 2 * (n - 1); i++) { edge e = edgeset[i]; if (!same(e.u, e.v)) { unite(e.u ,e.v); res += e.w; } } return res; } int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &p[i].x, &p[i].y); p[i].id = i + 1; } sort(p, p + n, cmp_x); for (int i = 0; i < n - 1; i++) { edgeset[i].u = p[i].id; edgeset[i].v = p[i + 1].id; edgeset[i].w = abs(p[i + 1].x - p[i].x); } sort(p, p + n, cmp_y); for (int i = 0; i < n - 1; i++) { edgeset[i + n - 1].u = p[i].id; edgeset[i + n - 1].v = p[i + 1].id; edgeset[i + n - 1].w = abs(p[i + 1].y - p[i].y); } sort(edgeset, edgeset + 2 * (n - 1), cmp_edge); printf("%d\n", mst()); return 0; }
a.cc: In function 'void init()': a.cc:19:12: error: reference to 'rank' is ambiguous 19 | memset(rank, 0, sizeof(rank)); | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:19:28: error: reference to 'rank' is ambiguous 19 | memset(rank, 0, sizeof(rank)); | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:22:9: error: reference to 'rank' is ambiguous 22 | rank[i] = 0; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:37:9: error: reference to 'rank' is ambiguous 37 | if (rank[x] < rank[y]) pa[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:37:19: error: reference to 'rank' is ambiguous 37 | if (rank[x] < rank[y]) pa[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:40:13: error: reference to 'rank' is ambiguous 40 | if (rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:40:24: error: reference to 'rank' is ambiguous 40 | if (rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~ a.cc:40:33: error: reference to 'rank' is ambiguous 40 | if (rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:14:5: note: 'int rank [100010]' 14 | int rank[MAX_N]; | ^~~~
s800402362
p03684
C++
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<cstring> #include<cctype> #include<queue> #include<stack> #include<map> #include<set> #include<iomanip> #include<cstdlib> #include<ctime> #include<list> #define ull unsigned long long #define ll long long #define pii pair<int,int > #define iiii pair<int,pii > #define MAXN 100020 using namespace std; int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; vector<pii >vX,vY; set<pair<int,pii > >Set; ll res=0; int n; void fInit(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } int fFind(int x) { if(par[x]==x) return x; return par[x]=fFind(par[x]); } ll fUnite(int x,int y) { x=fFind(x);y=fFind(y); if(x==y)return false; if(rank[x]<rank[y])par[x]=y; else { par[y]=x; if(rank[x]==rank[y])rank[x]++; } return 1; } int know(int x,int y) { return abs(x-y); } int main() { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d%d",X+i,Y+i); vX.push_back(make_pair(X[i],i)); vY.push_back(make_pair(Y[i],i)); } fInit(n); sort(vX.begin(),vX.end()); sort(vY.begin(),vY.end()); for(int i=0;i<n-1;i++) { Set.insert(make_pair(know(vX[i+1].first,vX[i].first),make_pair(vX[i+1].second,vX[i].second))); Set.insert(make_pair(know(vY[i+1].first,vY[i].first),make_pair(vY[i+1].second,vY[i].second))); } while (Set.size()) { set<iiii >::iterator it=Set.begin(); res+=fUnite((*it).second.second,(*it).second.first)*(ll)(*it).first; Set.erase(it); } cout<<res<<endl; return 0; }
a.cc: In function 'void fInit(int)': a.cc:35:17: error: reference to 'rank' is ambiguous 35 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc: In function 'long long int fUnite(int, int)': a.cc:49:12: error: reference to 'rank' is ambiguous 49 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:49:20: error: reference to 'rank' is ambiguous 49 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:20: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:29: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:37: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~
s511315432
p03684
C++
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<cstring> #include<cctype> #include<queue> #include<stack> #include<map> #include<set> #include<iomanip> #include<cstdlib> #include<ctime> #include<list> #define ull unsigned long long #define ll long long #define pii pair<int,int > #define iiii pair<int,pii > #define MAXN 100020 using namespace std; int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; vector<pii >vX,vY; set<pair<int,pii > >Set; ll res=0; int n; void fInit(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } int fFind(int x) { if(par[x]==x) return x; return par[x]=fFind(par[x]); } ll fUnite(int x,int y) { x=fFind(x);y=fFind(y); if(x==y)return false; if(rank[x]<rank[y])par[x]=y; else { par[y]=x; if(rank[x]==rank[y])rank[x]++; } return 1; } int know(int x,int y) { return abs(x-y); } int main() { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d%d",X+i,Y+i); vX.push_back(make_pair(X[i],i)); vY.push_back(make_pair(Y[i],i)); } fInit(n); sort(vX.begin(),vX.end()); sort(vY.begin(),vY.end()); for(int i=0;i<n-1;i++) { Set.insert(make_pair(know(vX[i+1].first,vX[i].first),make_pair(vX[i+1].second,vX[i].second))); Set.insert(make_pair(know(vY[i+1].first,vY[i].first),make_pair(vY[i+1].second,vY[i].second))); } while (Set.size()) { set<iiii >::iterator it=Set.begin(); res+=fUnite((*it).second.second,(*it).second.first)*(ll)(*it).first; Set.erase(it); } cout<<res<<endl; return 0; }
a.cc: In function 'void fInit(int)': a.cc:35:17: error: reference to 'rank' is ambiguous 35 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc: In function 'long long int fUnite(int, int)': a.cc:49:12: error: reference to 'rank' is ambiguous 49 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:49:20: error: reference to 'rank' is ambiguous 49 | if(rank[x]<rank[y])par[x]=y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:20: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:29: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~ a.cc:53:37: error: reference to 'rank' is ambiguous 53 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:24:31: note: 'int rank [100020]' 24 | int X[MAXN],Y[MAXN],par[MAXN],rank[MAXN]; | ^~~~
s348549774
p03684
C++
#include <iostream> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define mp make_pair const int maxn = 100005; int px[maxn],py[maxn],f[maxn]; pair<int,int> sx[maxn],sy[maxn]; int fnd(int x){ if (f[x]==x)return x; return f[x]=fnd(f[x]); } int n; int dist(int u,int v){ return min(abs(px[u]-px[v]),abs(py[u]-py[v])); } int unit(int x,int y){ x=fnd(x); y=fnd(y); if (x==y)return 0; f[x]=y; return 1; } int main(){ scanf("%d",&n); for (int i=0;i<n;++i){ scanf("%d%d",&px[i],&py[i]); f[i]=i; sx[i]=mp(px[i],i); sy[i]=mp(py[i],i); } sort(sx,sx+n); sort(sy,sy+n); set < pair < int , pair < int , int > > >st; for (int i=0;i<n-1;++i){ st.insert(mp(dist(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second))); st.insert(mp(dist(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second))); } long long res=0; while ((int)st.size()){ auto pair<int,pair<int,int> > cur= *(st.begin()); st.erase(cur); int u=cur.second.first,v=cur.second.second; res += unit(u,v) * dist(u,v); } printf("%lld\n",res); return 0; }
a.cc: In function 'int main()': a.cc:54:47: error: invalid declarator before 'cur' 54 | auto pair<int,pair<int,int> > cur= *(st.begin()); | ^~~ a.cc:55:26: error: 'cur' was not declared in this scope 55 | st.erase(cur); | ^~~ a.cc:57:31: error: 'v' was not declared in this scope 57 | res += unit(u,v) * dist(u,v); | ^
s720227977
p03684
C++
#include <bits/stdc++.h> using namespace std; #define mp make_pair const int maxn = 100005; int px[maxn],py[maxn],f[maxn]; pair<int,int> sx[maxn],sy[maxn]; int fnd(int x){ if (f[x]==x)return x; return f[x]=fnd(f[x]); } int n; int dist(int u,int v){ return min(abs(px[u]-px[v]),abs(py[u]-py[v])); } int unit(int x,int y){ x=fnd(x); y=fnd(y); if (x==y)return 0; f[x]=y; return 1; } int main(){ scanf("%d",&n); for (int i=0;i<n;++i){ scanf("%d%d",&px[i],&py[i]); f[i]=i; sx[i]=mp(px[i],i); sy[i]=mp(py[i],i); } sort(sx,sx+n); sort(sy,sy+n); set < pair < int , pair < int , int > > >st; for (int i=0;i<n-1;++i){ st.insert(mp(dist(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second))); st.insert(mp(dist(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second))); } long long res=0; while ((int)st.size()){ auto pair<int,pair<int,int> > cur= *(st.begin()); st.erase(cur); int u=cur.second.first,v=cur.second.second; res += unit(u,v) * dist(u,v); } printf("%lld\n",res); return 0; }
a.cc: In function 'int main()': a.cc:49:47: error: invalid declarator before 'cur' 49 | auto pair<int,pair<int,int> > cur= *(st.begin()); | ^~~ a.cc:50:26: error: 'cur' was not declared in this scope 50 | st.erase(cur); | ^~~ a.cc:52:31: error: 'v' was not declared in this scope 52 | res += unit(u,v) * dist(u,v); | ^
s488749387
p03684
C++
#include <bits/stdc++.h> using namespace std; #define mp make_pair const int maxn = 100005; int px[maxn],py[maxn],f[maxn]; pair<int,int> sx[maxn],sy[maxn]; int fnd(int x){ if (f[x]==x)return x; return f[x]=fnd(f[x]); } int n; int dist(int u,int v){ return min(abs(px[u]-px[v]),abs(py[u]-py[v])); } int unit(int x,int y){ x=fnd(x); y=fnd(y); if (x==y)return 0; f[x]=y; return 1; } int main(){ scanf("%d",&n); for (int i=0;i<n;++i){ scanf("%d%d",&px[i],&py[i]); f[i]=i; sx[i]=mp(px[i],i); sy[i]=mp(py[i],i); } sort(sx,sx+n); sort(sy,sy+n); set < pair < int , pair < int , int > > >st; for (int i=0;i<n-1;++i){ st.insert(mp(dist(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second))); st.insert(mp(dist(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second))); } long long res=0; while ((int)st.size()){ auto pair<int,pair<int,int> > cur= *(st.begin()); st.erase(cur); int u=cur.second.first,v=cur.second.second; res += unit(u,v) * dist(u,v); } printf("%lld\n",res); return 0; }
a.cc: In function 'int main()': a.cc:49:47: error: invalid declarator before 'cur' 49 | auto pair<int,pair<int,int> > cur= *(st.begin()); | ^~~ a.cc:50:26: error: 'cur' was not declared in this scope 50 | st.erase(cur); | ^~~ a.cc:52:31: error: 'v' was not declared in this scope 52 | res += unit(u,v) * dist(u,v); | ^
s073657044
p03684
C++
asdadadasdasdasdasdadadasdasdasd asdadadasdasdasd asdadadasdasdasd asdadadasdasdasd
a.cc:2:1: error: 'asdadadasdasdasdasdadadasdasdasd' does not name a type 2 | asdadadasdasdasdasdadadasdasdasd | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s621927878
p03684
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 100005 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; struct edge{int from, to; ll cost;}; ll cost[MAX][MAX]; ll mincost[MAX]; priority_queue<Pll, vector<Pll>, greater<Pll> > que; bool used[MAX]; int V; ll prim(){ fill(mincost, mincost+V, INF); fill(used, used+V, false); que.push(make_pair(0, 0)); int res = 0; while(true){ Pll v; while(!que.empty()){ if(!used[que.top().second]){ v = que.top(); break; } que.pop(); } if(que.empty()) break; used[v.second] = true; res += v.first; rep(V){ mincost[i] = min(mincost[i], cost[v.second][i]); que.push(make_pair(mincost[i], i)); } } return res; } signed main(){ //scanf("%d", &V); cin >> V; vector<ll> x(V), y(V); rep(V){ //scanf("%lld %lld", &x[i], &y[i]); cin >> x[i] >> y[i]; repp(j, i){ cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j])); } } printf("%lld\n", prim()); return 0; }
/tmp/ccH7p88f.o: in function `prim()': a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o a.cc:(.text+0x125): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s739024991
p03684
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 100005 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; struct edge{int from, to; ll cost;}; ll cost[MAX][MAX]; ll mincost[MAX]; priority_queue<Pll, vector<Pll>, greater<Pll> > que; bool used[MAX]; int V; ll prim(){ fill(mincost, mincost+V, INF); fill(used, used+V, false); que.push(make_pair(0, 0)); int res = 0; while(true){ Pll v; while(!que.empty()){ if(!used[que.top().second]){ v = que.top(); break; } que.pop(); } if(que.empty()) break; used[v.second] = true; res += v.first; rep(V){ mincost[i] = min(mincost[i], cost[v.second][i]); que.push(make_pair(mincost[i], i)); } } return res; } signed main(){ scanf("%d", &V); vector<ll> x(V), y(V); rep(V){ scanf("%lld %lld", &x[i], &y[i]); repp(j, i){ cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j])); } } printf("%lld\n", prim()); return 0; }
/tmp/ccPnO4lF.o: in function `prim()': a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o a.cc:(.text+0x125): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s872785421
p03684
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 100005 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; struct edge{int from, to; ll cost;}; ll cost[MAX][MAX]; ll mincost[MAX]; priority_queue<Pll, vector<Pll>, greater<Pll> > que; bool used[MAX]; int V; ll prim(){ fill(mincost, mincost+V, INF); fill(used, used+V, false); que.push(make_pair(0, 0)); int res = 0; while(true){ Pll v; while(!que.empty()){ if(!used[que.top().second]){ v = que.top(); break; } que.pop(); } if(que.empty()) break; used[v.second] = true; res += v.first; rep(V){ mincost[i] = min(mincost[i], cost[v.second][i]); que.push(make_pair(mincost[i], i)); } } return res; } signed main(){ scanf("%d", &V); vector<ll> x(V), y(V); rep(V){ scanf("%lld %lld", &x[i], &y[i]); repp(j, i){ cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j])); } } printf("%lld\n", prim()); }
/tmp/ccarWuqy.o: in function `prim()': a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o a.cc:(.text+0x125): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s863179008
p03684
C++
#include <algorithm> #include <cstdio> #include <cstdlib> #include <utility> using namespace std; #define MAX_N 100000+10 #define MAX_E 4*(100000+10) int par[MAX_N]; int rank[MAX_N]; void init_union_find(int n) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } int find_union_find(int x){ if (par[x] == x) { return x; } else { return par[x] = find_union_find(par[x]); } } void unite_union_find(int x, int y) { x = find_union_find(x); y = find_union_find(y); if ( x == y) return; if (rank[x] < rank[y] ) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) { rank[x]++; } } } bool same_union_find(int x, int y) { return find_union_find(x) == find_union_find(y); } struct edge{int u,v, cost;}; bool comp(const edge& e1, const edge& e2) { return e1.cost < e2.cost; } edge es[MAX_E]; int V,E; int kruskal() { sort(es, es+E, comp); init_union_find(V); int res=0; for(int i=0;i<E;++i) { edge e =es[i]; if(!same_union_find(e.u,e.v)){ unite_union_find(e.u, e.v); res += e.cost; } } return res; } typedef pair<int,int> city_data; city_data x[MAX_N]; city_data y[MAX_N]; int main() { int N; scanf("%d", &N); for(int i=0;i<N;++i){ scanf("%d%d", &x[i].first, &y[i].first); x[i].second = i; y[i].second = i; } V=N; sort(x, x+N); sort(y, y+N); int it=0; for(int i=0;i<N-1;++i){ { int cost=abs(x[i].first - x[i+1].first); es[it].u=x[i].second; es[it].v=x[i+1].second; es[it].cost=cost; it++; } { int cost=abs(y[i].first - y[i+1].first); es[it].u=y[i].second; es[it].v=y[i+1].second; es[it].cost=cost; it++; } } E=it; printf("%d",kruskal()); return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:15:5: error: reference to 'rank' is ambiguous 15 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc: In function 'void unite_union_find(int, int)': a.cc:32:7: error: reference to 'rank' is ambiguous 32 | if (rank[x] < rank[y] ) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:32:17: error: reference to 'rank' is ambiguous 32 | if (rank[x] < rank[y] ) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:36:9: error: reference to 'rank' is ambiguous 36 | if (rank[x] == rank[y]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:36:20: error: reference to 'rank' is ambiguous 36 | if (rank[x] == rank[y]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~ a.cc:37:7: error: reference to 'rank' is ambiguous 37 | rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:5: note: 'int rank [100010]' 10 | int rank[MAX_N]; | ^~~~
s933465851
p03684
C++
class Edge: def __init__(self, u, v, cost): self.u = u self.v = v self.cost = cost # self.n = n class Coordinate: def __init__(self, x, y, n): self.x = x self.y = y self.n = n def __repr__(self): return repr((self.x, self.y)) # union find。初期化 def init(_n): for i in range(0, _n): par[i] = i rank[i] = 0 # 木の根を求める def find(_x): if par[_x] == _x: return _x else: par[_x] = find(par[_x]) return par[_x] # 集合を併合 def unite(_x, _y): _x = find(_x) _y = find(_y) if _x == _y: return if rank[_x] < rank[_y]: par[_x] = _y else: par[_y] = _x if rank[_x] == rank[_y]: rank[_x] += 1 # 同じ集合かどうか def same(_x, _y): return find(_x) == find(_y) def comp(edge1, edge2): return edge1.cost < edge2.cost def kruskal(): sorted_edges = sorted(Edges, key=lambda edges: edges.cost) init(V) res = 0 # for i in range(E): # # print("u" + str(sorted_edges[i].u) + "v" + str(sorted_edges[i].v) + "cost" + str(sorted_edges[i].cost)) for i in range(0, E): tmp_edge = sorted_edges[i] if not same(tmp_edge.u, tmp_edge.v): unite(tmp_edge.u, tmp_edge.v) # print("tmp_edge.cost" + str(tmp_edge.cost)) res += tmp_edge.cost return res if __name__ == '__main__': N = int(input()) x = [] y = [] Coordinates = [] for i in range(0, N): tmp_x, tmp_y = list(map(int, input().split())) # x.append(tmp_x) # y.append(tmp_y) Coordinates.append(Coordinate(tmp_x, tmp_y, i)) sorted_by_x = sorted(Coordinates, key=lambda coordinate: coordinate.x) sorted_by_y = sorted(Coordinates, key=lambda coordinate: coordinate.y) Edges = [] for i in range(0, N - 1): cost_x = min(abs(sorted_by_x[i].x - sorted_by_x[i + 1].x), abs(sorted_by_x[i].y - sorted_by_x[i + 1].y)) Edges.append(Edge(sorted_by_x[i].n, sorted_by_x[i + 1].n, cost_x)) # Edges.append(Edge(sorted_by_x[i + 1].n, sorted_by_x[i].n, cost_x)) cost_y = min(abs(sorted_by_y[i].x - sorted_by_y[i + 1].x), abs(sorted_by_y[i].y - sorted_by_y[i + 1].y)) Edges.append(Edge(sorted_by_y[i].n, sorted_by_y[i + 1].n, cost_y)) # Edges.append(Edge(sorted_by_y[i + 1].n, sorted_by_y[i].n, cost_y)) par = [0 for i in range(N)] rank = [0 for i in range(N)] V = N E = 2 * (N - 1) print(kruskal())
a.cc:6:11: error: invalid preprocessing directive #self 6 | # self.n = n | ^~~~ a.cc:19:3: error: invalid preprocessing directive #union 19 | # union find。初期化 | ^~~~~ a.cc:19:9: error: extended character 。 is not valid in an identifier 19 | # union find。初期化 | ^ a.cc:26:3: error: invalid preprocessing directive #\U00006728\U0000306e\U00006839\U00003092\U00006c42\U00003081\U0000308b 26 | # 木の根を求める | ^~~~~~~~~~~~~~ a.cc:35:3: error: invalid preprocessing directive #\U000096c6\U00005408\U00003092\U00004f75\U00005408 35 | # 集合を併合 | ^~~~~~~~~~ a.cc:50:3: error: invalid preprocessing directive #\U0000540c\U00003058\U000096c6\U00005408\U0000304b\U00003069\U00003046\U0000304b 50 | # 同じ集合かどうか | ^~~~~~~~~~~~~~~~ a.cc:63:7: error: invalid preprocessing directive #for 63 | # for i in range(E): | ^~~ a.cc:64:7: error: invalid preprocessing directive ## 64 | # # print("u" + str(sorted_edges[i].u) + "v" + str(sorted_edges[i].v) + "cost" + str(sorted_edges[i].cost)) | ^ a.cc:70:15: error: invalid preprocessing directive #print 70 | # print("tmp_edge.cost" + str(tmp_edge.cost)) | ^~~~~ a.cc:76:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 76 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:83:11: error: invalid preprocessing directive #x 83 | # x.append(tmp_x) | ^ a.cc:84:11: error: invalid preprocessing directive #y 84 | # y.append(tmp_y) | ^ a.cc:94:11: error: invalid preprocessing directive #Edges 94 | # Edges.append(Edge(sorted_by_x[i + 1].n, sorted_by_x[i].n, cost_x)) | ^~~~~ a.cc:97:11: error: invalid preprocessing directive #Edges 97 | # Edges.append(Edge(sorted_by_y[i + 1].n, sorted_by_y[i].n, cost_y)) | ^~~~~ a.cc:2:9: error: expected class-name before '__init__' 2 | def __init__(self, u, v, cost): | ^~~~~~~~ a.cc:2:9: error: expected '{' before '__init__' a.cc:2:18: error: 'self' was not declared in this scope 2 | def __init__(self, u, v, cost): | ^~~~ a.cc:2:24: error: 'u' was not declared in this scope 2 | def __init__(self, u, v, cost): | ^ a.cc:2:27: error: 'v' was not declared in this scope 2 | def __init__(self, u, v, cost): | ^ a.cc:2:30: error: 'cost' was not declared in this scope; did you mean 'const'? 2 | def __init__(self, u, v, cost): | ^~~~ | const a.cc:2:34: error: expression list treated as compound expression in initializer [-fpermissive] 2 | def __init__(self, u, v, cost): | ^
s013588953
p03684
C++
#include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <cmath> #include <map> using namespace std; typedef long long ll; struct edge {int u,v,cost;}; int par[100001],Rank[100001]; edge es[200002]; int N; bool comp(const edge& e1,const edge& e2){ return e1.cost<e2.cost; } void init_union_find(int n){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x)return x; else return x=find(par[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(x==y)return ; if(rank[x]<rank[y]){ par[x]=y; } else{ par[y]=x; if(rank[x]==rank[y])rank[x]++; } } bool same(int x,int y){ return find(x) == find(y); } int main(){ cin >> N; vector<pair<int ,int> > p(N),p2(N); for(int i=0;i<N;i++){ int x,y; cin >> x >> y; p[i]=make_pair(x,i); p2[i]=make_pair(y,i); } sort(p.begin(),p.end()); sort(p2.begin(),p2.end()); for(int i=0;i<N-1;i++){ es[i].u=p[i].second; es[i].v=p[i+1].second; es[i].cost=p[i+1].first-p[i].first; } for(int i=0;i<N-1;i++){ es[N-1+i].u=p2[i].second; es[N-1+i].v=p2[i+1].second; es[N-1+i].cost=p2[i+1].first-p2[i].first; } sort(es,es+2*(N-1),comp); //for(int i=0;i<2*(N-1);i++) printf("%d %d %d\n",es[i].u,es[i].v,es[i].cost); init_union_find(N); ll res=0; for(int i=0;i<2*(N-1);i++){ edge e=es[i]; if(!same(e.u,e.v)){ unite(e.u,e.v); res+=e.cost; } } cout << res << endl; return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:20:10: error: redeclaration of 'auto i' 20 | rank[i]=0; | ^ a.cc:18:11: note: 'int i' previously declared here 18 | for(int i=0;i<n;i++){ | ^ a.cc:20:13: error: class template argument deduction failed: 20 | rank[i]=0; | ^ a.cc:20:13: error: no matching function for call to 'rank(int)' In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank()-> std::rank< <template-parameter-1-1> >' 1437 | struct rank | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank(std::rank< <template-parameter-1-1> >)-> std::rank< <template-parameter-1-1> >' /usr/include/c++/14/type_traits:1437:12: note: template argument deduction/substitution failed: a.cc:20:13: note: mismatched types 'std::rank< <template-parameter-1-1> >' and 'int' 20 | rank[i]=0; | ^ a.cc: In function 'void unite(int, int)': a.cc:32:10: error: expected unqualified-id before '[' token 32 | if(rank[x]<rank[y]){ | ^ a.cc:37:12: error: expected unqualified-id before '[' token 37 | if(rank[x]==rank[y])rank[x]++; | ^ a.cc:37:32: error: expected initializer before '++' token 37 | if(rank[x]==rank[y])rank[x]++; | ^~ a.cc:37:32: error: expected ';' before '++' token
s162901908
p03684
C++
#include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <cmath> #include <map> using namespace std; typedef long long ll; struct edge {int u,v,cost;}; int par[100001],rank[100001]; edge es[200002]; int N; bool comp(const edge& e1,const edge& e2){ return e1.cost<e2.cost; } void init_union_find(int n){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x)return x; else return x=find(par[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(x==y)return ; if(rank[x]<rank[y]){ par[x]=y; } else{ par[y]=x; if(rank[x]==rank[y])rank[x]++; } } bool same(int x,int y){ return find(x) == find(y); } int main(){ cin >> N; vector<pair<int ,int> > p(N),p2(N); for(int i=0;i<N;i++){ int x,y; cin >> x >> y; p[i]=make_pair(x,i); p2[i]=make_pair(y,i); } sort(p.begin(),p.end()); sort(p2.begin(),p2.end()); for(int i=0;i<N-1;i++){ es[i].u=p[i].second; es[i].v=p[i+1].second; es[i].cost=p[i+1].first-p[i].first; } for(int i=0;i<N-1;i++){ es[N-1+i].u=p2[i].second; es[N-1+i].v=p2[i+1].second; es[N-1+i].cost=p2[i+1].first-p2[i].first; } sort(es,es+2*(N-1),comp); //for(int i=0;i<2*(N-1);i++) printf("%d %d %d\n",es[i].u,es[i].v,es[i].cost); init_union_find(N); ll res=0; for(int i=0;i<2*(N-1);i++){ edge e=es[i]; if(!same(e.u,e.v)){ unite(e.u,e.v); res+=e.cost; } } cout << res << endl; return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:20:5: error: reference to 'rank' is ambiguous 20 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:32:6: error: reference to 'rank' is ambiguous 32 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~ a.cc:32:14: error: reference to 'rank' is ambiguous 32 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~ a.cc:37:8: error: reference to 'rank' is ambiguous 37 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~ a.cc:37:17: error: reference to 'rank' is ambiguous 37 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~ a.cc:37:25: error: reference to 'rank' is ambiguous 37 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:10:17: note: 'int rank [100001]' 10 | int par[100001],rank[100001]; | ^~~~
s361251261
p03684
Java
import java.util.*; public class Main { static ArrayList<Edge>[] graph; static int vNum; public static void main(String[] args) { Scanner sc = new Scanner(System.in); vNum = sc.nextInt(); Vertice[] V = new Vertice[vNum]; graph = new ArrayList[vNum]; for(int i = 0; i < vNum; i++) { graph[i] = new ArrayList<Edge>(); } for(int i = 0; i < vNum; i++) { int x = sc.nextInt(); int y = sc.nextInt(); V[i] = new Vertice(i, x, y); } Arrays.sort(V, new Comparator<Vertice>() { public int compare(Vertice vertice1, Vertice vertice2) { return vertice1.x - vertice2.x; } }); for(int i = 0; i < vNum - 1; i++) { Vertice v1 = V[i]; Vertice v2 = V[i + 1]; graph[v1.id].add(new Edge(v2.id, v2.x - v1.x)); graph[v2.id].add(new Edge(v1.id, v2.x - v1.x)); } Arrays.sort(V, new Comparator<Vertice>() { public int compare(Vertice vertice1, Vertice vertice2) { return vertice1.y - vertice2.y; } }); for(int i = 0; i < vNum - 1; i++) { Vertice v1 = V[i]; Vertice v2 = V[i + 1]; graph[v1.id].add(new Edge(v2.id, v2.y - v1.y)); graph[v2.id].add(new Edge(v1.id, v2.y - v1.y)); } int ans = prim(); System.out.println(ans); } public static int prim() { int total = 0; Queue<Edge> que = new PriorityQueue<Edge>(); que.add(new Edge(0,0)); boolean[] use = new boolean[vNum]; while(!que.isEmpty()) { Edge e = que.poll(); if(use[e.to]) { continue; } use[e.to] = true; total += e.cost; for(Edge e2 : graph[e.to]) { que.add(e2); } } return total; } static class Edge implements Comparable { int to; int cost; public Edge(int to, int cost) { this.to = to; this.cost = cost; } @Override public int compareTo(Edge o) { return this.cost - o.cost; } } static class Vertice { int id; int x; int y; public Vertice(int id, int x, int y) { this.id = id; this.x = x; this.y = y; } } }
Main.java:66: error: Edge is not abstract and does not override abstract method compareTo(Object) in Comparable static class Edge implements Comparable { ^ Main.java:74: error: method does not override or implement a method from a supertype @Override ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors
s389736305
p03684
C++
#include <iostream> #include <vector> #include <cmath> using namespace std; struct union_find { const int root_v = -1; vector<int> d; union_find(int n) : d(n, root_v) {} int root(int i) { return d[i] == root_v ? i : root(d[i]); } bool is_connect(int i, int j) { return root(i) == root(j); } void connect(int i, int j) { d[i] = j; } }; struct city { int index; int x; int y; }; struct path { int s, g; int cost; }; int main() { cin.tie(0); ios::sync_with_stdio(false); long n; cin >> n; vector<city> cs(n); for (int i = 0; i < n; i++) { cs[i].index = i; cin >> cs[i].x >> cs[i].y; } vector<path> e; sort(cs.begin(), cs.end(), [](city r, city l){ return r.x < l.x;}); for (int i = 0; i < cs.size() - 1; i++) { e.push_back(path {cs[i].index, cs[i+1].index, cs[i+1].x - cs[i].x}); } sort(cs.begin(), cs.end(), [](city r, city l){ return r.y < l.y;}); for (int i = 0; i < cs.size() - 1; i++) { e.push_back(path {cs[i].index, cs[i+1].index, cs[i+1].y - cs[i].y}); } sort(e.begin(), e.end(), [](path r, path l){return r.cost < l.cost;}); int cost = 0; union_find uf(n); for (path p : e) { if (!uf.is_connect(p.s, p.g)) { uf.connect(p.s, p.g); cost += p.cost; } } cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 52 | sort(cs.begin(), cs.end(), [](city r, city l){ return r.x < l.x;}); | ^~~~ | sqrt
s086583291
p03684
C++
#include <iostream> #include <sstream> #include <cstdio> #include <cmath> #include <cctype> #include <cstring> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <deque> #include <stack> #include <queue> #include <list> #include <map> #include <set> #include <utility> #include <bitset> using namespace std; // #define DEBUG 1 #ifdef DEBUG #define NDEBUG #include "cout11.h" #endif #undef NDEBUG #include <cassert> typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> ii; typedef pair<ll,ll> llll; typedef pair<double,double> dd; #define sz(a) int((a).size()) #define pb push_back #define FOR(var,from,to) for(int var=(from);var<=(to);++var) #define rep(var,n) for(int var=0;var<(n);++var) #define rep1(var,n) for(int var=1;var<=(n);++var) #define repC2(vari,varj,n) for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj) #define ALL(c) (c).begin(),(c).end() #define tr(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define found(s,e) ((s).find(e)!=(s).end()) #define mset(arr,val) memset(arr,val,sizeof(arr)) #define mid(x,y) ((x)+((y)-(x))/2) #define foreqr(eqr,mm,v) for (auto eqr=mm.equal_range(v);eqr.first!=eqr.second;++eqr.first) #define lower_index(s,v) (int)(lower_bound(s.begin(),s.end(),v)-s.begin()) #define upper_index(s,v) (int)(upper_bound(s.begin(),s.end(),v)-s.begin()) #define INTSPACE 11 char _buf[INTSPACE*1000000 + 3]; // ここ要確認 int loadint() { fgets(_buf, INTSPACE+3, stdin); return atoi(_buf); } int loadvec(vector<int>& v, int N) { int bufsize = INTSPACE*N + 3; fgets(_buf, bufsize, stdin); v.resize(N); int i=0; bool last = false; for (char *p=&_buf[0]; ;) { char *q = p; while (*q > ' ') ++q; if (*q == 0x0D || *q == 0x0A) last = true; *q = 0; v[i++] = atoi(p); if (last || i == N) break; p = q+1; } // assert(i <= N); return i; } class UnionFind { vector<int> data; public: UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; //auto it##eqr=mm.equal_range(v);for(auto it=it##eqr.first,end=it##eqr.second;it!=end;++it) ll solve(int n, vector<int>&x, vector<int>&y) { // UnionFind uf(n); assert(x.size() == n && y.size() == n); vector<bool> vis(n, false); multimap<int, int> xx,xxv,xxa, yy,yyv,yya; multimap<int, ii> ox; multimap<int, ii> oy; vis[0] = true; ll cost = 0; auto initialize = [](int n, vector<bool>& vis, vector<int>& x, multimap<int,int>& xx, multimap<int,int>& xxv, multimap<int,int>& xxa, multimap<int,ii>& ox, const char *x_y) { #ifdef VERBOSE printf("<%s> initializing...\n", x_y); #endif rep(i, n) { xx.insert(ii(x[i], i)); if (vis[i]) { xxv.insert(ii(x[i], i)); } else { xxa.insert(ii(x[i], i)); } } int i_at_lastV = -1, xi_at_lastV = -1; int i_at_lastA = -1, xi_at_lastA = -1; #ifdef VERBOSE cout << "xx:" << xx << endl; #endif for (auto xxj : xx) { int xi = xxj.first, i = xxj.second; if (vis[i]) { // V if (i_at_lastA != -1) { assert(i != i_at_lastA); int d = abs(xi - xi_at_lastA); ox.insert( pair<int, ii>(d, ii(i, i_at_lastA)) ); } i_at_lastV = i; xi_at_lastV = xi; } else { // A if (i_at_lastV != -1) { assert(i != i_at_lastV); int d = abs(xi_at_lastV - xi); ox.insert( pair<int, ii>(d, ii(i_at_lastV, i)) ); } i_at_lastA = i; xi_at_lastA = xi; } } }; initialize(n,vis,x,xx,xxv,xxa,ox, "x"); initialize(n,vis,y,yy,yyv,yya,oy, "y"); for (int z=1; z<n; ++z) { auto take_the_smallest = [](vector<bool>& vis, multimap<int,ii>& ox, ll& cost, int& v, int& a) { auto ox0 = ox.begin(); if (ox0 == ox.end()) { v = a = -1; return; } while (vis[ox0->second.second]) ++ox0; cost += ox0->first; v = ox0->second.first; a = ox0->second.second; }; auto fn0 = [](vector<bool>& vis, multimap<int,ii>& ox) { for (auto ax=ox.begin(); ax!=ox.end(); ++ax) { if (!vis[ax->second.second]) { return ax->first; } } return INT_MAX; }; int x_nearest = fn0(vis, ox); int y_nearest = fn0(vis, oy); if (x_nearest == INT_MAX && y_nearest == INT_MAX) { assert(false); } int v, a; if (x_nearest < y_nearest) { take_the_smallest(vis,ox, cost,v,a); } else { take_the_smallest(vis,oy, cost,v,a); } vis[a] = true; { auto move_a_from_xxa_to_xxv = [](vector<int>& x, multimap<int,int>& xxa, multimap<int,int>& xxv, int a, const char *x_y) { // foreqr(eqr,xxa,x[a]) { // if (eqr.first->second == a) { xxa.erase(eqr.first++); eqr.first--; break; } // } xxv.insert(ii(x[a], a)); }; move_a_from_xxa_to_xxv(x,xxa,xxv,a, "x"); move_a_from_xxa_to_xxv(y,yya,yyv,a, "y"); auto update_ox = [](vector<bool>& vis, vector<int>& x, multimap<int,int>& xxa, multimap<int,ii>& ox, int a, const char *x_y) { auto ax = xxa.lower_bound(x[a]), bx = ax; while (ax != xxa.end()) { int i = ax->second; if (i != a && !vis[i]) { ox.insert( pair<int, ii>(abs(x[a] - x[i]), ii(a, i)) ); break; } if (ax == xxa.begin()) break; --ax; } while (bx != xxa.end()) { int i = bx->second; if (i != a && !vis[i]) { ox.insert( pair<int, ii>(abs(x[a] - x[i]), ii(a, i)) ); break; } ++bx; } }; update_ox(vis,x,xxa,ox,a, "x"); update_ox(vis,y,yya,oy,a, "y"); } } return cost; } int main(){ int N = loadint(); vector<int> tmp(2); vector<int> x(N), y(N); rep(i, N) { loadvec(tmp, 2); x[i]=tmp[0]; y[i]=tmp[1]; } printf("%lld\n", solve(N, x, y)); return 0; }
a.cc: In lambda function: a.cc:176:20: error: 'INT_MAX' was not declared in this scope 176 | return INT_MAX; | ^~~~~~~ a.cc:30:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 29 | #include <cassert> +++ |+#include <climits> 30 | a.cc: In function 'll solve(int, std::vector<int>&, std::vector<int>&)': a.cc:180:26: error: 'INT_MAX' was not declared in this scope 180 | if (x_nearest == INT_MAX && y_nearest == INT_MAX) { | ^~~~~~~ a.cc:180:26: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s583481413
p03684
C
#include<bits/stdc++.h> using namespace std; #define m make_pair #define I int #define t first #define u second pair<I,I>x[1<<17],y[1<<17];I i,n,p[1<<17],s; pair<I,pair<I,I> > G[2<<17]; I f(I a){return p[a]-a?p[a]=f(p[a]):a;} main() { for(cin>>n;i++<n;x[i].u=y[i].u=p[i]=i)cin>>x[i].t>>y[i].t; sort(x+1,x+n+1),sort(y+1,y+n+1); for(i=0;++i<n;) { G[i*2] = m(abs(x[i].t-x[i+1].t),m(x[i].u,x[i+1].u)); G[i*2+1] = m(abs(y[i].t-y[i+1].t),m(y[i].u,y[i+1].u)); } sort(G,G+n*2); for(i=0;i<2*n-2;i++) { I x=G[i].u.t,y=G[i].u.u; if(f(x)-f(y)) { s+=G[i].t; p[f(x)]=f(y); } } cout<<s<<endl; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s213796222
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; struct edge { int u,v,cost; }; int n; int x[10010] int y[10010]; int par[11010] int rank[10010]; vector<edge> ki; long long ans; void init_union_find(int n) { for(int i = 0;i < n;i++) { par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x,int y) { x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; } else{ par[y] = x; if(rank[x] == rank[y])rank[y]++; } } bool same(int x,int y) { return find(x) == find(y); } bool comp(const edge& e1,const edge& e2) { return e1.cost < e2.cost; } int kruskal() { sort(ki.begin(),ki.end(),comp); init_union_find(n); int res = 0; for(int i = 0;i < ki.size();i++) { edge e = ki[i]; if(!same(e.u,e.v)) { unite(e.u,e.v); res += e.cost; } } return res; } int main() { cin >> n; for(int i = 0;i < n;i++) { cin >> x[i] >> y[i]; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { edge k; k.u = i;k.v = j; k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); // cout << k.cost << endl; ki.push_back(k); } } ans = kruskal(); cout << ans << endl; return 0; }
a.cc:17:1: error: expected initializer before 'int' 17 | int y[10010]; | ^~~ a.cc:19:1: error: expected initializer before 'int' 19 | int rank[10010]; | ^~~ a.cc: In function 'void init_union_find(int)': a.cc:27:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 27 | par[i] = i; | ^~~ | __pstl::execution::v1::par In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15, from /usr/include/c++/14/algorithm:86, from a.cc:5: /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc:28:22: error: redeclaration of 'auto i' 28 | rank[i] = 0; | ^ a.cc:25:17: note: 'int i' previously declared here 25 | for(int i = 0;i < n;i++) | ^ a.cc:28:27: error: class template argument deduction failed: 28 | rank[i] = 0; | ^ a.cc:28:27: error: no matching function for call to 'rank(int)' In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank()-> std::rank< <template-parameter-1-1> >' 1437 | struct rank | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank(std::rank< <template-parameter-1-1> >)-> std::rank< <template-parameter-1-1> >' /usr/include/c++/14/type_traits:1437:12: note: template argument deduction/substitution failed: a.cc:28:27: note: mismatched types 'std::rank< <template-parameter-1-1> >' and 'int' 28 | rank[i] = 0; | ^ a.cc: In function 'int find(int)': a.cc:34:12: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 34 | if(par[x] == x) | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc: In function 'void unite(int, int)': a.cc:50:16: error: expected unqualified-id before '[' token 50 | if(rank[x] < rank[y]){ | ^ a.cc:51:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 51 | par[x] = y; | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc:53:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 53 | par[y] = x; | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc:54:24: error: expected unqualified-id before '[' token 54 | if(rank[x] == rank[y])rank[y]++; | ^ a.cc:54:46: error: expected initializer before '++' token 54 | if(rank[x] == rank[y])rank[y]++; | ^~ a.cc:54:46: error: expected ';' before '++' token a.cc: In function 'int main()': a.cc:93:24: error: 'x' was not declared in this scope 93 | cin >> x[i] >> y[i]; | ^ a.cc:93:32: error: 'y' was not declared in this scope 93 | cin >> x[i] >> y[i]; | ^ a.cc:101:42: error: 'x' was not declared in this scope 101 | k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); | ^ a.cc:101:57: error: 'y' was not declared in this scope 101 | k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); | ^
s540352037
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; struct edge { int u,v,cost; }; int n; int x[10010],y[10010]; static int par[11010],rank[10010]; vector<edge> ki; long long ans; void init_union_find(int n) { for(int i = 0;i < n;i++) { par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x,int y) { x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; } else{ par[y] = x; if(rank[x] == rank[y])rank[y]++; } } bool same(int x,int y) { return find(x) == find(y); } bool comp(const edge& e1,const edge& e2) { return e1.cost < e2.cost; } int kruskal() { sort(ki.begin(),ki.end(),comp); init_union_find(n); int res = 0; for(int i = 0;i < ki.size();i++) { edge e = ki[i]; if(!same(e.u,e.v)) { unite(e.u,e.v); res += e.cost; } } return res; } int main() { cin >> n; for(int i = 0;i < n;i++) { cin >> x[i] >> y[i]; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { edge k; k.u = i;k.v = j; k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); // cout << k.cost << endl; ki.push_back(k); } } ans = kruskal(); cout << ans << endl; return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:26:17: error: reference to 'rank' is ambiguous 26 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:48:12: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~ a.cc:48:22: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~ a.cc:52:20: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~ a.cc:52:31: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~ a.cc:52:39: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:23: note: 'int rank [10010]' 17 | static int par[11010],rank[10010]; | ^~~~
s168870912
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; struct edge { int u,v,cost; }; int n; int x[10010],y[10010]; int par[11010],rank[10010]; vector<edge> ki; long long ans; void init_union_find(int n) { for(int i = 0;i < n;i++) { par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x,int y) { x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; } else{ par[y] = x; if(rank[x] == rank[y])rank[y]++; } } bool same(int x,int y) { return find(x) == find(y); } bool comp(const edge& e1,const edge& e2) { return e1.cost < e2.cost; } int kruskal() { sort(ki.begin(),ki.end(),comp); init_union_find(n); int res = 0; for(int i = 0;i < ki.size();i++) { edge e = ki[i]; if(!same(e.u,e.v)) { unite(e.u,e.v); res += e.cost; } } return res; } int main() { cin >> n; for(int i = 0;i < n;i++) { cin >> x[i] >> y[i]; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { edge k; k.u = i;k.v = j; k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); // cout << k.cost << endl; ki.push_back(k); } } ans = kruskal(); cout << ans << endl; return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:26:17: error: reference to 'rank' is ambiguous 26 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:48:12: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:48:22: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:20: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:31: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:39: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~
s778124505
p03684
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; struct edge { int u,v,cost; }; int n; int x[10010],y[10010]; int par[11010],rank[10010]; vector<edge> ki; long long ans; void init_union_find(int n) { for(int i = 0;i < n;i++) { par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x,int y) { x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; } else{ par[y] = x; if(rank[x] == rank[y])rank[y]++; } } bool same(int x,int y) { return find(x) == find(y); } bool comp(const edge& e1,const edge& e2) { return e1.cost < e2.cost; } int kruskal() { sort(ki.begin(),ki.end(),comp); init_union_find(n); int res = 0; for(int i = 0;i < ki.size();i++) { edge e = ki[i]; if(!same(e.u,e.v)) { unite(e.u,e.v); res += e.cost; } } return res; } int main() { cin >> n; for(int i = 0;i < n;i++) { cin >> x[i] >> y[i]; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { edge k; k.u = i;k.v = j; k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j])); // cout << k.cost << endl; ki.push_back(k); } } ans = kruskal(); cout << ans << endl; return 0; }
a.cc: In function 'void init_union_find(int)': a.cc:26:17: error: reference to 'rank' is ambiguous 26 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:48:12: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:48:22: error: reference to 'rank' is ambiguous 48 | if(rank[x] < rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:20: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:31: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~ a.cc:52:39: error: reference to 'rank' is ambiguous 52 | if(rank[x] == rank[y])rank[y]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:16: note: 'int rank [10010]' 17 | int par[11010],rank[10010]; | ^~~~
s738976178
p03684
C
#include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <cstdlib> #include <climits> using namespace std; typedef unsigned long long ull; typedef long long ll; ull N; struct UnionFind { vector<int> par; vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { for(int i=0;i<n;++i) par[i] = i; } int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (sizes[x] < sizes[y]) swap(x, y); par[y] = x; sizes[x] += sizes[y]; sizes[y] = 0; } void unite(pair<int,int> p) { unite(p.first,p.second); } bool same(int x, int y) { return find(x) == find(y); } bool same(pair<int,int> p) { return same(p.first,p.second); } int size(int x) { return sizes[find(x)]; } }; void fillmap(vector<pair<int,int>> xs, map<pair<int,int>,int> &m){ for(auto it=xs.begin();it+1!=xs.end();++it) { int diff = abs(it->first-(it+1)->first); int t = it->second, n = (it+1)->second; auto key = t<n ? make_pair(t,n) : make_pair(n,t); m[key] = m.count(key) ? min(diff, m[key]) : diff; } } int main (int argc, char const *argv[]) { cin >> N; vector< pair<int,int> > xs,ys; for(int i=1;i<=N;++i) { int x,y;cin >> x >> y; xs.push_back(make_pair(x,i)); ys.push_back(make_pair(y,i)); } sort(xs.begin(),xs.end()); sort(ys.begin(),ys.end()); map< pair<int,int>,int > m; fillmap(xs,m); fillmap(ys,m); priority_queue< pair< int, pair<int,int> > > pq; for(auto &&kv:m) pq.push(make_pair(-kv.second,kv.first)); auto uf = UnionFind(N+1); ll ans=0; while(pq.size()) { auto t = pq.top(); pq.pop(); // cout << t.first << " : " << t.second.first << "," << t.second.second << endl; if(uf.same(t.second)) continue; uf.unite(t.second); ans += -t.first; } cout << ans << endl; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s619328976
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct edge{int from, to, cost; edge (int f, int t, int c) : from(f),to(t),cost(c) {} }; int N; typedef pair<int,int> P; bool operator < (const edge& a, const edge& b){ return a.cost < b.cost; } vector<P>x,y; vector<edge> e; int p[100001]; int rank[100001]; void init(int N) { for(int i = 0; i < N; i++) { p[i] = i; rank[i] = 0; } } int Find(int x) { if(x == p[x]) return x; return p[x] = Find(p[x]); } bool Union(int x, int y) { int a = Find(x); int b = Find(y); if(a == b) return false; if(rank[a] > rank[b]) p[b] = a; else { p[a] = b; if(rank[a] == rank[b]) rank[a]++; } return true; } int main() { cin >> N; for(int i = 0; i < N; i++) { int xx,yy; cin >> xx >> yy; x.push_back(P(xx,i)); y.push_back(P(yy,i)); } sort(x.begin(),x.end()); sort(y.begin(),y.end()); for(int i = 1; i < N; i++) { int xx = x[i].first - x[i-1].first; int yy = y[i].first - y[i-1].first; e.push_back(edge(x[i].second,x[i-1].second,xx)); e.push_back(edge(x[i-1].second,x[i].second,xx)); e.push_back(edge(y[i].second,y[i-1].second,yy)); e.push_back(edge(y[i-1].second,y[i].second,yy)); } sort(e.begin(),e.end()); init(N); ll ans = 0; for(int i = 0; i < e.size(); i++) { if(Union(e[i].from,e[i].to)) ans += e[i].cost; } cout << ans << endl; }
a.cc: In function 'void init(int)': a.cc:22:5: error: reference to 'rank' is ambiguous 22 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~ a.cc: In function 'bool Union(int, int)': a.cc:36:6: error: reference to 'rank' is ambiguous 36 | if(rank[a] > rank[b]) p[b] = a; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~ a.cc:36:16: error: reference to 'rank' is ambiguous 36 | if(rank[a] > rank[b]) p[b] = a; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~ a.cc:40:8: error: reference to 'rank' is ambiguous 40 | if(rank[a] == rank[b]) rank[a]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~ a.cc:40:19: error: reference to 'rank' is ambiguous 40 | if(rank[a] == rank[b]) rank[a]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~ a.cc:40:28: error: reference to 'rank' is ambiguous 40 | if(rank[a] == rank[b]) rank[a]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:5: note: 'int rank [100001]' 17 | int rank[100001]; | ^~~~
s303106778
p03684
C++
#include <cstdio> #include <cstring> #include <cstdlib> #include <vector> #include <queue> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <cmath> using namespace std; const int maxn=100000+5; typedef long long ll; struct point{int x,y,id;}; point p[maxn]; int n; struct edge{int from,to,cost;}; vector<edge> pool; int myabs(int x){return x<0?-x:x;} bool cmppp(edge a,edge b){ return a.cost<b.cost; } bool cmp1(point a,point b){ if(a.x==b.x) return a.y<b.y; return a.x<b.x; } bool cmp2(point a,point b){ if(a.y==b.y) return a.x<b.x; return a.y<b.y; } struct ge{int to,cost;}; struct cmpp{ bool operator()(edge a,edge b){ return a.cost>b.cost; } }; vector<ge> g[maxn]; int f[maxn],rnk[maxn]; int getf(int x){ return f[x]==x?f[x]:f[x]=getf(f[x]); } void merge(int u,int v) { int fu=getf(u),fv=getf(v); if(fu==fv) return; else{ if(rnk[fu]>rnk[fv]){ rnk[fu]+=rnk[fv];rnk[fv]=0; f[fv]=fu; }else{ rnk[fv]+=rnk[fu];rnk[fu]=0; f[fu]=fv; } } } vector<edge> egs; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) {p[i].id=i;scanf("%d%d",&p[i].x,&p[i].y);} sort(p+1,p+1+n,cmp1); for(int i=1;i<n;i++){ egs.push_back((edge){p[i].id,p[i+1].id,min(myabs(p[i].x-p[i+1].x),myabs(p[i].y-p[i+1].y))}); } sort(p+1,p+1+n,cmp2); for(int i=1;i<n;i++){ egs.push_back((edge){p[i].id,p[i+1].id,min(myabs(p[i].x-p[i+1].x),myabs(p[i].y-p[i+1].y))}); } bool has=true; for(int i=1;i<=n;i++) f[i]=i; for(int i=1;i<=n;i++) rnk[i]=1; ll ans=0; sort(egs.begin(),egs.end(),cmppp); memset(vis,0,sizeof(vis)); int lev=n-1; for(int i=0;i<egs.size();i++) { edge now=egs[i]; if(getf(now.from)!=getf(now.to)) {lev--;vis[i]=true;merge(now.from,now.to);ans+=now.cost;} if(lev==0) break; } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:75:16: error: 'vis' was not declared in this scope 75 | memset(vis,0,sizeof(vis)); | ^~~
s647626319
p03684
Java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author HossamDoma */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskD solver = new TaskD(); solver.solve(1, in, out); out.close(); } static class TaskD { int n; int id; int sz; public void solve(int testNumber, InputReader in, PrintWriter out) { n = in.nextInt(); id = new int[n + 2]; sz = new int[n + 2]; Arrays.fill(sz, 1); TaskD.XX Xs[] = new TaskD.XX[n]; TaskD.XX Ys[] = new TaskD.XX[n]; for (int i = 0; i < n; ++i) { int a = in.nextInt(); int b = in.nextInt(); id[i + 1] = i + 1; Xs[i] = new TaskD.XX(a, i); Ys[i] = new TaskD.XX(b, i); } Arrays.sort(Xs, (o1, o2) -> { if (o1.v < o2.v) return -1; else if (o1.v > o2.v) return 1; else return 0; }); Arrays.sort(Ys, (o1, o2) -> { if (o1.v < o2.v) return -1; else if (o1.v > o2.v) return 1; else return 0; }); ArrayList<TaskD.Point> pts = new ArrayList<>(); for (int i = 0; i + 1 < n; ++i) { pts.add(new TaskD.Point(Math.abs(Xs[i].v - Xs[i + 1].v), Xs[i].idd + 1, Xs[i + 1].idd + 1)); pts.add(new TaskD.Point(Math.abs(Ys[i].v - Ys[i + 1].v), Ys[i].idd + 1, Ys[i + 1].idd + 1)); } pts.sort((o1, o2) -> { if (o1.d < o2.d) return -1; else if (o1.d > o2.d) return 1; else return 0; }); // // for(Point x : pts) // out.println(x.d + " " + x.a + " " + x.b); int ans = 0; for (TaskD.Point x : pts) { if (!find(x.a, x.b)) { // out.println(x.a + " " + x.b + " " + x.d); union(x.a, x.b); ans += x.d; } if (sz[root(x.a)] == n || sz[root(x.b)] == n) break; } out.println(ans); } private boolean find(int p, int q) { return root(p) == root(q); } private int root(int i) { while (i != id[i]) { // Simple path-compression (link child to grandparent). id[i] = id[id[i]]; // one line to keep it ALMOST flat. i = id[i]; } return i; } private void union(int p, int q) { int i = root(p); int j = root(q); if (i == j) return; // connected to the same root! // Keeping it logarithmic O(log N) at most. // Linking the smaller tree to the bigger. if (sz[i] >= sz[j]) { id[j] = i; sz[i] += sz[j]; } else { id[i] = j; sz[j] += sz[i]; } } static class Point { int d; int a; int b; Point(int d, int a, int b) { this.d = d; this.a = a; this.b = b; } } static class XX { int v; int idd; XX(int v, int dd) { this.v = v; this.idd = dd; } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Main.java:38: error: incompatible types: int[] cannot be converted to int id = new int[n + 2]; ^ Main.java:39: error: incompatible types: int[] cannot be converted to int sz = new int[n + 2]; ^ Main.java:41: error: no suitable method found for fill(int,int) Arrays.fill(sz, 1); ^ method Arrays.fill(long[],long) is not applicable (argument mismatch; int cannot be converted to long[]) method Arrays.fill(int[],int) is not applicable (argument mismatch; int cannot be converted to int[]) method Arrays.fill(short[],short) is not applicable (argument mismatch; int cannot be converted to short[]) method Arrays.fill(char[],char) is not applicable (argument mismatch; int cannot be converted to char[]) method Arrays.fill(byte[],byte) is not applicable (argument mismatch; int cannot be converted to byte[]) method Arrays.fill(boolean[],boolean) is not applicable (argument mismatch; int cannot be converted to boolean[]) method Arrays.fill(double[],double) is not applicable (argument mismatch; int cannot be converted to double[]) method Arrays.fill(float[],float) is not applicable (argument mismatch; int cannot be converted to float[]) method Arrays.fill(Object[],Object) is not applicable (argument mismatch; int cannot be converted to Object[]) Main.java:49: error: array required, but int found id[i + 1] = i + 1; ^ Main.java:96: error: array required, but int found if (sz[root(x.a)] == n || sz[root(x.b)] == n) ^ Main.java:96: error: array required, but int found if (sz[root(x.a)] == n || sz[root(x.b)] == n) ^ Main.java:110: error: array required, but int found while (i != id[i]) { ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:115: error: array required, but int found i = id[i]; ^ Main.java:133: error: array required, but int found if (sz[i] >= sz[j]) { ^ Main.java:133: error: array required, but int found if (sz[i] >= sz[j]) { ^ Main.java:134: error: array required, but int found id[j] = i; ^ Main.java:135: error: array required, but int found sz[i] += sz[j]; ^ Main.java:135: error: array required, but int found sz[i] += sz[j]; ^ Main.java:137: error: array required, but int found id[i] = j; ^ Main.java:138: error: array required, but int found sz[j] += sz[i]; ^ Main.java:138: error: array required, but int found sz[j] += sz[i]; ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 19 errors
s010812079
p03684
Java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author HossamDoma */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskD solver = new TaskD(); solver.solve(1, in, out); out.close(); } static class TaskD { int n; int id; int sz; public void solve(int testNumber, InputReader in, PrintWriter out) { n = in.nextInt(); id = new int[n + 2]; sz = new int[n + 2]; Arrays.fill(sz, 1); TaskD.XX Xs[] = new TaskD.XX[n]; TaskD.XX Ys[] = new TaskD.XX[n]; for (int i = 0; i < n; ++i) { int a = in.nextInt(); int b = in.nextInt(); id[i + 1] = i + 1; Xs[i] = new TaskD.XX(a, i); Ys[i] = new TaskD.XX(b, i); } Arrays.sort(Xs, (o1, o2) -> { if (o1.v < o2.v) return -1; else if (o1.v > o2.v) return 1; else return 0; }); Arrays.sort(Ys, (o1, o2) -> { if (o1.v < o2.v) return -1; else if (o1.v > o2.v) return 1; else return 0; }); ArrayList<TaskD.Point> pts = new ArrayList<>(); for (int i = 0; i + 1 < n; ++i) { pts.add(new TaskD.Point(Math.abs(Xs[i].v - Xs[i + 1].v), Xs[i].idd + 1, Xs[i + 1].idd + 1)); pts.add(new TaskD.Point(Math.abs(Ys[i].v - Ys[i + 1].v), Ys[i].idd + 1, Ys[i + 1].idd + 1)); } pts.sort((o1, o2) -> { if (o1.d < o2.d) return -1; else if (o1.d > o2.d) return 1; else return 0; }); // // for(Point x : pts) // out.println(x.d + " " + x.a + " " + x.b); int ans = 0; for (TaskD.Point x : pts) { if (!find(x.a, x.b)) { // out.println(x.a + " " + x.b + " " + x.d); union(x.a, x.b); ans += x.d; } if (sz[root(x.a)] == n || sz[root(x.b)] == n) break; } out.println(ans); } private boolean find(int p, int q) { return root(p) == root(q); } private int root(int i) { while (i != id[i]) { // Simple path-compression (link child to grandparent). id[i] = id[id[i]]; // one line to keep it ALMOST flat. i = id[i]; } return i; } private void union(int p, int q) { int i = root(p); int j = root(q); if (i == j) return; // connected to the same root! // Keeping it logarithmic O(log N) at most. // Linking the smaller tree to the bigger. if (sz[i] >= sz[j]) { id[j] = i; sz[i] += sz[j]; } else { id[i] = j; sz[j] += sz[i]; } } static class Point { int d; int a; int b; Point(int d, int a, int b) { this.d = d; this.a = a; this.b = b; } } static class XX { int v; int idd; XX(int v, int dd) { this.v = v; this.idd = dd; } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Main.java:38: error: incompatible types: int[] cannot be converted to int id = new int[n + 2]; ^ Main.java:39: error: incompatible types: int[] cannot be converted to int sz = new int[n + 2]; ^ Main.java:41: error: no suitable method found for fill(int,int) Arrays.fill(sz, 1); ^ method Arrays.fill(long[],long) is not applicable (argument mismatch; int cannot be converted to long[]) method Arrays.fill(int[],int) is not applicable (argument mismatch; int cannot be converted to int[]) method Arrays.fill(short[],short) is not applicable (argument mismatch; int cannot be converted to short[]) method Arrays.fill(char[],char) is not applicable (argument mismatch; int cannot be converted to char[]) method Arrays.fill(byte[],byte) is not applicable (argument mismatch; int cannot be converted to byte[]) method Arrays.fill(boolean[],boolean) is not applicable (argument mismatch; int cannot be converted to boolean[]) method Arrays.fill(double[],double) is not applicable (argument mismatch; int cannot be converted to double[]) method Arrays.fill(float[],float) is not applicable (argument mismatch; int cannot be converted to float[]) method Arrays.fill(Object[],Object) is not applicable (argument mismatch; int cannot be converted to Object[]) Main.java:49: error: array required, but int found id[i + 1] = i + 1; ^ Main.java:96: error: array required, but int found if (sz[root(x.a)] == n || sz[root(x.b)] == n) ^ Main.java:96: error: array required, but int found if (sz[root(x.a)] == n || sz[root(x.b)] == n) ^ Main.java:110: error: array required, but int found while (i != id[i]) { ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:113: error: array required, but int found id[i] = id[id[i]]; // one line to keep it ALMOST flat. ^ Main.java:115: error: array required, but int found i = id[i]; ^ Main.java:133: error: array required, but int found if (sz[i] >= sz[j]) { ^ Main.java:133: error: array required, but int found if (sz[i] >= sz[j]) { ^ Main.java:134: error: array required, but int found id[j] = i; ^ Main.java:135: error: array required, but int found sz[i] += sz[j]; ^ Main.java:135: error: array required, but int found sz[i] += sz[j]; ^ Main.java:137: error: array required, but int found id[i] = j; ^ Main.java:138: error: array required, but int found sz[j] += sz[i]; ^ Main.java:138: error: array required, but int found sz[j] += sz[i]; ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 19 errors
s087833646
p03684
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #define inf 1145141919 #define llinf 1145141919810364364 #define mod 1000000007 int max(int a,int b){if(a>b){return a;}return b;} int min(int a,int b){if(a<b){return a;}return b;} int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;} int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;} int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;} int nCr(int a,int b){int i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;} int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} long long llmax(long long a,long long b){if(a>b){return a;}return b;} long long llmin(long long a,long long b){if(a<b){return a;}return b;} long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;} long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;} long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;} long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;} long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} double dbmax(double a,double b){if(a>b){return a;}return b;} double dbmin(double a,double b){if(a<b){return a;}return b;} int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;} int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;} int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;} int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;} typedef struct{ int coor; int node; } data; typedef struct{ int leng; int node1; int node2; } way; int datsortfncsj(const void *a,const void *b){if(((*(data *)a)->coor)>((*(data *)b)->coor){return 1;}if(((*(data *)a)->coor)==((*(data *)b)->coor){return 0;}return -1;} int waysortfncsj(const void *a,const void *b){if(((*(way *)a)->leng)>((*(way *)b)->leng){return 1;}if(((*(way *)a)->leng)==((*(way *)b)->leng){return 0;}return -1;} int main(void){ int x[131072],y[131072],n,i,j,check[131072]={0},st=1; long long res=0; data xdat[131072],ydat[131072]; way waydat[524288]; scanf("%d",&n); for(i=0;i<n;i++){scanf("%d%d",&x[i],&y[i]);} for(i=0;i<n;i++){ xdat[i].coor=x[i];xdat[i].node=i; ydat[i].coor=y[i];ydat[i].node=i; } qsort(xdat,n,sizeof(data),datsortfncsj); qsort(ydat,n,sizeof(data),datsortfncsj); for(i=0;i<n-1;i++){ waydat[2*i].leng=xdat[i+1].coor-xdat[i].coor; waydat[2*i].node1=xdat[i].node; waydat[2*i].node2=xdat[i+1].node; waydat[2*i+1].leng=ydat[i+1].coor-ydat[i].coor; waydat[2*i+1].node1=ydat[i].node; waydat[2*i+1].node2=ydat[i+1].node; } qsort(waydat,2*(n-1),sizeof(way),waysortfncsj); for(i=0;i<2*(n-1);i++){ if(i==0){ check[waydat[i].node1]=1; check[waydat[i].node2]=1; res+=waydat[i].leng; } else{ if(check[waydat[i].node1] == check[waydat[i].node2] && check[waydat[i].node1] != 0){continue;} if(check[waydat[i].node1] == check[waydat[i].node2] && check[waydat[i].node1] == 0){ res+=waydat[i].leng;st++;check[waydat[i].node1]=st;check[waydat[i].node2]=st; } else{ res+=waydat[i].leng; for(j=0;j<n;j++){if(check[waydat[i].node1] == check[j]){check[j] = check[waydat[i].node2]}} } } } printf("%lld\n",res); return 0; }
main.c:10:5: warning: conflicting types for built-in function 'round'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 10 | int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~ main.c:4:1: note: 'round' is declared in header '<math.h>' 3 | #include<stdlib.h> +++ |+#include <math.h> 4 | #define inf 1145141919 main.c:11:5: warning: conflicting types for built-in function 'ceil'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 11 | int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;} | ^~~~ main.c:11:5: note: 'ceil' is declared in header '<math.h>' main.c:16:5: warning: conflicting types for built-in function 'pow'; expected 'double(double, double)' [-Wbuiltin-declaration-mismatch] 16 | int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} | ^~~ main.c:16:5: note: 'pow' is declared in header '<math.h>' main.c:19:11: warning: conflicting types for built-in function 'llround'; expected 'long long int(double)' [-Wbuiltin-declaration-mismatch] 19 | long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~~~ main.c:19:11: note: 'llround' is declared in header '<math.h>' main.c: In function 'datsortfncsj': main.c:45:63: error: invalid type argument of '->' (have 'data') 45 | int datsortfncsj(const void *a,const void *b){if(((*(data *)a)->coor)>((*(data *)b)->coor){return 1;}if(((*(data *)a)->coor)==((*(data *)b)->coor){return 0;}return -1;} | ^~ main.c:45:84: error: invalid type argument of '->' (have 'data') 45 | int datsortfncsj(const void *a,const void *b){if(((*(data *)a)->coor)>((*(data *)b)->coor){return 1;}if(((*(data *)a)->coor)==((*(data *)b)->coor){return 0;}return -1;} | ^~ main.c:45:91: error: expected ')' before '{' token 45 | int datsortfncsj(const void *a,const void *b){if(((*(data *)a)->coor)>((*(data *)b)->coor){return 1;}if(((*(data *)a)->coor)==((*(data *)b)->coor){return 0;}return -1;} | ~ ^ | ) main.c:89:1: error: expected declaration or statement at end of input 89 | } | ^
s665313455
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define M 1000000007 #define N 100005 int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0; struct zb{ int x, y,id,prx,pry; }a[N]; int cmp(const int i, const int j){return w[i]<w[j];} int cmp1(struct zb i, struct zb j){return i.x<j.x;} int cmp2(struct zb i, struct zb j){return i.y<j.y;} int fin(int x){return p[x]==x?x:p[x]=fin(p[x]);} LL kru() { LL ans=0; for(int i=0;i<n;i++) p[i]=i; for(int i=0;i<m;i++) r[i]=i; sort(r,r+m,cmp); for(int i=0;i<m;i++) { int e=r[i]; int x=fin(u[e]); int y=fin(v[e]); if(x!=y){ans+=w[e];p[x]=y;} } return ans; } int main() { scanf("%d",&n); m=(n-1)*2; for(i=0;i<n;i++) {scanf("%d%d",&a[i].x,&a[i].y);a[i].id=i;} sort(a,a+n,cmp1); for(i=n-1;i>0;i--) {a[i].x=a[i].x-a[i-1].x;a[i].prx=a[i-1].id;} for(i=1;i<=n-1;i++) { u[k]=a[i].id;v[k]=a[i].prx;w[k++]=a[i].x; } sort(a,a+n,cmp2); for(i=n-1;i>0;i--) {a[i].y=a[i].y-a[i-1].y; a[i].pry=a[i-1].id;} for(i=1;i<=n-1;i++) { u[k]=a[i].id;v[k]=a[i].pry;w[k++]=a[i].y; } printf("%lld",kru()); return 0; }
a.cc:6:8: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow] 6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0; | ^ a.cc:6:8: error: size of array 'u' exceeds maximum object size '9223372036854775807' a.cc:6:15: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow] 6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0; | ^ a.cc:6:15: error: size of array 'v' exceeds maximum object size '9223372036854775807' a.cc:6:27: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow] 6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0; | ^ a.cc:6:27: error: size of array 'r' exceeds maximum object size '9223372036854775807' a.cc:6:34: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow] 6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0; | ^ a.cc:6:34: error: size of array 'w' exceeds maximum object size '9223372036854775807'
s662905164
p03684
C++
#include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <map> using namespace std; #define MAX_V 120000 #define MAX_E 220000 typedef pair<int, int> P; int par[MAX_V]; int rank[MAX_V]; // n要素で初期化 void init(int n){ for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 0; } } // 木の根を求める int find(int x){ if(par[x] == x){ return x; } return par[x] = find(par[x]); } // xとyの属する集合を併合 void unite(int x, int y){ int x_par = find(x); int y_par = find(y); if(x_par == y_par){ return; } if(rank[x_par] < rank[y_par]){ par[x_par] = y_par; }else{ par[y_par] = x_par; if(rank[x_par] == rank[y_par]){ rank[x_par]++; } } } bool same(int x, int y){ return (find(x) == find(y)); } struct edge{ int u, v, cost; }; bool comp(const edge& e1, const edge& e2){ return e1.cost < e2.cost; } edge es[MAX_E]; int V, E; int kruskal(){ sort(es, es + E, comp); init(V); int res = 0; for(int i = 0; i < E; i++){ edge e = es[i]; if(!same(e.u, e.v)){ unite(e.u, e.v); res += e.cost; } } return res; } int main(){ int N; cin >> N; vector<P> v1, v2; for(int i = 0; i < N; i++){ int x, y; cin >> x >> y; P p; p.first = x; p.second = i; v1.push_back(p); p.first = y; v2.push_back(p); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); V = N; E = 2 * N - 2; for(int i = 0; i < N - 1; i++){ es[i].u = v1[i].second; es[i].v = v1[i + 1].second; es[i].cost = v1[i + 1].first - v1[i].first; } for(int i = 0; i < N - 1; i++){ es[i + N - 1].u = v2[i].second; es[i + N - 1].v = v2[i + 1].second; es[i + N - 1].cost = v2[i + 1].first - v2[i].first; } for(int i = 0; i < E; i++){ //cout << es[i].u << " " << es[i].v << " " << es[i].cost << endl; } int ans = kruskal(); cout << ans << endl; return 0; }
a.cc: In function 'void init(int)': a.cc:22:17: error: reference to 'rank' is ambiguous 22 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:42:12: error: reference to 'rank' is ambiguous 42 | if(rank[x_par] < rank[y_par]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~ a.cc:42:26: error: reference to 'rank' is ambiguous 42 | if(rank[x_par] < rank[y_par]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~ a.cc:46:20: error: reference to 'rank' is ambiguous 46 | if(rank[x_par] == rank[y_par]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~ a.cc:46:35: error: reference to 'rank' is ambiguous 46 | if(rank[x_par] == rank[y_par]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~ a.cc:47:25: error: reference to 'rank' is ambiguous 47 | rank[x_par]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:16:5: note: 'int rank [120000]' 16 | int rank[MAX_V]; | ^~~~
s725180650
p03684
C++
#include <algorithm> #include <cfloat> #include <climits> #include <cstring> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> # ifdef __GNUC__ # if __cplusplus > 199711L # include <unordered_set> # include <unordered_map> # else # include <tr1/unordered_map> # include <tr1/unordered_set> using namespace tr1; # endif # else # include <unordered_map> # include <unordered_set> # endif using namespace std; #define fi first #define se second #define FO(x, n) for (int x = 0; x < n; ++x) #define FOR(x, a, b) for (int x = a; x < b; ++x) #define RFO(x, n) for (int x = n - 1; x >= 0; --x) #define RFOR(x, a, b) for (int x = b - 1; x >= a; --x) typedef unsigned char byte; typedef unsigned int uint; typedef long long llong; typedef unsigned long long ullong; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<llong, llong> pll; inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; } const int MAXN = 100100; int N; pii pos[MAXN]; bool in[MAXN]; vector<int> edge[MAXN]; unordered_map<int, unordered_set<int>> has; int dist(int a, int b) { return min(abs(pos[a].fi - pos[b].fi), abs(pos[a].se - pos[b].se)); } int main() { while (cin >> N) { has.clear(); memset(in, 0, sizeof(in)); xs.clear(); ys.clear(); FO (i, N) { int x, y; cin >> x >> y; if (has[x].count(y)) in[i] = true; has[x].insert(y); } priority_queue<pii, vector<pii>, greater<pii>> que; in[0] = true; FO (i, N) if (!in[i]) que.push(pii(dist(0, i), i)); llong res = 0; while (!que.empty()) { pii d_u = que.top(); que.pop(); int d = d_u.fi; int u = d_u.se; if (in[u]) continue; res += d; in[u] = true; FO (i, N) if (!in[i]) que.push(pii(dist(u, i), i)); } cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:65:9: error: 'xs' was not declared in this scope 65 | xs.clear(); | ^~ a.cc:66:9: error: 'ys' was not declared in this scope; did you mean 'yn'? 66 | ys.clear(); | ^~ | yn
s044214285
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define r(i,n) for(int i=0;i<n;i++) #define MAX 100001 struct edge{int u,v,cost;}; pair<int,int>a[MAX]; int par[MAX]; int rank[MAX]; void init(int n){ r(i,n){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } void unit(int x,int y){ x=find(x); y=find(y); if(x==y)return; if(rank[x]<rank[y]){ par[x]=y; }else{ par[y]=x; if(rank[x]==rank[y])rank[x]++; } } bool comp(const edge& e1,const edge& e2){ return e1.cost<e2.cost; } bool same(int x,int y){ return find(x)==find(y); } vector<edge> es; int V,E; int prim(){ sort(es.begin(),es.end(),comp); init(V); int res=0; for(int i=0;i<E;i++){ edge e=es[i]; if(!same(e.u,e.v)){ unit(e.u,e.v); res+=e.cost; } } return res; } main(){ cin>>V; r(i,V){ cin>>a[i].first>>a[i].second; } r(i,V)r(j,V){ edge e; e.u=i; e.v=j;E++; e.cost=min(abs(a[i].first-a[j].first),abs(a[i].second-a[j].second)); } cout<<prim()<<endl; }
a.cc: In function 'void init(long long int)': a.cc:13:5: error: reference to 'rank' is ambiguous 13 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc: In function 'void unit(long long int, long long int)': a.cc:27:6: error: reference to 'rank' is ambiguous 27 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc:27:14: error: reference to 'rank' is ambiguous 27 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc:31:8: error: reference to 'rank' is ambiguous 31 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc:31:17: error: reference to 'rank' is ambiguous 31 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc:31:25: error: reference to 'rank' is ambiguous 31 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'long long int rank [100001]' 9 | int rank[MAX]; | ^~~~ a.cc: At global scope: a.cc:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 55 | main(){ | ^~~~
s624968157
p03684
C++
#include <iostream> #include <queue> #include <map> #include <list> #include <vector> #include <string> #include <stack> #include <limits> #include <climits> #include <cassert> #include <fstream> #include <cstring> #include <cmath> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <cstdio> #include <ciso646> #include <set> #include <array> #include <unordered_map> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf 0x3f3f3f3f #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define SET(a,c) memset(a,c,sizeof a) #define CLR(a) memset(a,0,sizeof a) #define VS vector<string> #define VI vector<ll> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define MIN(a,b) (a>b?b:a) #define MAX(a,b) (a>b?a:b) #define pi 2*acos(0.0) #define INFILE() freopen("in0.txt","r",stdin) #define OUTFILE()freopen("out0.txt","w",stdout) #define ll long long #define ull unsigned long long #define pii pair<ll,ll> #define pcc pair<char,char> #define pic pair<ll,char> #define pci pair<char,ll> #define eps 1e-14 #define FST first #define SEC second #define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15) namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) :N(N_) {} template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template<typename T> operator T() const { T res; cin >> res; return res; } template<typename T> T operator - (T right) { return T(input_returnner()) - right; } template<typename T> T operator + (T right) { return T(input_returnner()) + right; } template<typename T> T operator * (T right) { return T(input_returnner()) * right; } template<typename T> T operator / (T right) { return T(input_returnner()) / right; } template<typename T> T operator << (T right) { return T(input_returnner()) << right; } template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; } }; template<typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } const ll MOD = 1e9 + 7; struct ModInt { ll v = 0; ModInt() {} template<class T> ModInt(const T& right) { v = right; if (v >= 0) v %= MOD; else v += ((-v) / MOD + 1)*MOD; v %= MOD; } void operator = (const ModInt& right) { v = right.v; } template<class T> void operator = (const T& right) { v = right; if (v >= 0) v %= MOD; else v = v += ((-v) / MOD + 1)*MOD; v %= MOD; } ModInt operator + (const ModInt& right) { return (v + right.v) % MOD; } ModInt operator - (const ModInt& right) { return (MOD - (v - right.v)); } ModInt operator * (const ModInt& right) { return (v * right.v) % MOD; } ModInt operator / (const ModInt& right) { return v / right.v; } void operator += (const ModInt& right) { v = (v + right.v) % MOD; } void operator -= (const ModInt& right) { v = (MOD - (v - right.v)); } void operator *= (const ModInt& right) { v = (v* right.v) % MOD; } void operator /= (const ModInt& right) { v = v / right.v; } bool operator == (const ModInt& right) { return v == right.v; } }; ostream& operator << (ostream& os, const ModInt& value) { os << value.v; return os; } void solve(); /// ---template--- signed main(void) { SETUP; solve(); return 0; } struct Edge { int f, t, c; Edge(int f_,int t_,int c_):f(f_),t(t_),c(c_){} Edge() {} }; template <class T> struct vector2 { T x; T y; vector2(T x_, T y_) :x(x_), y(y_) {} vector2() :x(0), y(0) {} vector2 operator + (const vector2<T>& right) { return vector2(x + right.x, y + right.y); } vector2 operator - (const vector2<T>& right) { return vector2(x - right.x, y - right.y); } T dot(const vector2<T>& right) { return x*right.x + y*right.y; } T det(const vector2<T>& right) { return (x*right.y) + (-y*right.x); } }; #define int long long class union_find { private: vector<int> par; vector<int> rank; vector<int> count; public: union_find(int N) :par(N), rank(N, 0), count(N, 1) { for (int i = 0; i < N; ++i) { par[i] = i; } } int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { count[y] += count[x]; par[x] = y; } else { count[x] += count[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } int getCount(int x) { return count[find(x)]; } void clean() { par = vector<int>(par.size()); } }; void solve() { int N; cin >> N; vector<pair<pii, int>> P(N); REP(i, N) { cin >> P[i].first.first >> P[i].first.second; P[i].second = i; } using mytype = pair<int, pair<int, int>>; priority_queue<mytype, vector<mytype>, greater<mytype>> q; sort(ALL(P)); REP(i, N-1) { q.push(MP( int(P[i + 1].first.first - P[i].first.first), MP( P[i].second, P[i+1].second ) )); } sort(ALL(P), [](const pair<pii,int>&left, const pair<pii,int>& right) -> bool{ if (left.first.second != right.first.second) { return left.first.second < right.first.second; } else left < right; } ); REP(i, N-1) { q.push(MP( int(P[i + 1].first.second - P[i].first.second), MP( P[i].second, P[i+1].second ) )); } union_find uf(N); int res = 0; while(not q.empty()){ auto a = q.top(); q.pop(); if (not uf.same(a.second.first, a.second.second)) { uf.unite(a.second.first, a.second.second); res += a.first; } } cout << res << endl; }
a.cc: In function 'void solve()': a.cc:138:13: error: expected primary-expression before 'long' 138 | #define int long long | ^~~~ a.cc:202:28: note: in expansion of macro 'int' 202 | q.push(MP( int(P[i + 1].first.first - P[i].first.first), MP( P[i].second, P[i+1].second ) )); | ^~~ a.cc:138:13: error: expected primary-expression before 'long' 138 | #define int long long | ^~~~ a.cc:213:28: note: in expansion of macro 'int' 213 | q.push(MP( int(P[i + 1].first.second - P[i].first.second), MP( P[i].second, P[i+1].second ) )); | ^~~ a.cc: In lambda function: a.cc:209:27: warning: control reaches end of non-void function [-Wreturn-type] 209 | else left < right; | ~~~~~^~~~~~~
s839326184
p03684
C++
#include <iostream> #include <cstring> #include <cmath> #include <vector> #include <queue> //#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> PI; typedef pair< PI, int> PII; #define pb push_back #define Key_value ch[ch[root][1]][0] #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define MS(x,y) memset(x,y,sizeof(x)) const double eps = 1e-6; const double pi = acos (-1.0); const int mod = 1e9 + 7; const int INF = 0x3f3f3f3f; const int M = 300005; const int maxn = 1e5 + 10; int n,pn,cnt,b[maxn],fa[maxn]; struct Point{ int x,y; int id; bool operator<(const Point& rhs) const { return x < rhs.x || (x == rhs.x && y < rhs.y); } } p[maxn]; struct Edge{ int u,v; LL d; bool operator<(const Edge& rhs) const { return d < rhs.d; } } e[maxn<<2]; void addEdge(int u,int v,LL d) { e[cnt].u = u; e[cnt].v = v; e[cnt++].d = d; } struct Bit{ int mn,pos; void init() { mn = INF; pos = -1; } } bit[maxn]; inline int lowbit(int x) { return x&-x; } void update(int x,int mn,int pos) { for(int i=x;i>0;i-=lowbit(i)) { if(bit[i].mn > mn) { bit[i].mn = mn; bit[i].pos = pos; } } } int query(int x) { int mn = INF,pos = -1; for(int i = x;i<=pn;i+=lowbit(i)) { if(bit[i].mn < mn) { mn = bit[i].mn; pos = bit[i].pos; } } return pos; } int find(int x) { return fa[x] == x?x:fa[x] = find(fa[x]); } LL solve() { cnt = 0; for(int dir = 0;dir<4;++dir) { if(dir&1) for(int i=0;i<n;++i) swap(p[i].x,p[i].y); if(dir == 2) for(int i=0;i<n;++i) p[i].x = -p[i].x; sort(p,p+n); for(int i=0;i<n;++i) b[i] = p[i].y - p[i].x; sort(b,b+n); pn = unique(b,b+n) - b; for(int i=1;i<=pn;++i) bit[i].init(); for(int i=n-1;i>=0;--i) { int pos = lower_bound(b,b+pn,p[i].y - p[i].x) - b + 1; int po = query(pos); if(po != -1) addEdge(p[i].id,p[po].id,min(abs(p[i].x-p[po].x) , abs(p[po].y-p[i].y))); update(pos,p[i].y + p[i].x,i); } } LL res = 0; for(int i=0;i<n;++i) fa[i] = i; sort(e,e+cnt); for(int i=0;i<cnt;++i) { int u = find(e[i].u),v = find(e[i].v); if(u != v) { fa[u] = v; res += e[i].d; } } return res; } int main() { cin >> n; for(int i=0;i<n;++i) { scanf("%d %d",&p[i].x,&p[i].y); p[i].id = i; } LL ans = solve(); cout << ans << endl; return 0; }
a.cc: In function 'LL solve()': a.cc:96:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 96 | sort(p,p+n); | ^~~~ | sqrt a.cc:99:14: error: 'unique' was not declared in this scope 99 | pn = unique(b,b+n) - b; | ^~~~~~ a.cc:112:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 112 | sort(e,e+cnt); | ^~~~ | sqrt
s655189383
p03684
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i)) using ll = long long; const int MAXV = 100010; const int INF = 1e8; int cost[MAXV][MAXV]; int mincost[MAXV]; bool used[MAXV]; int V; ll prim() { for (int i=0; i<V; ++i) { mincost[i] = INF; used[i] = false; } mincost[0] = 0; ll res = 0; while (true) { int v = -1; for (int u=0;u<V;++u) { if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u; } if (v == -1) break; used[v] = true; res += mincost[v]; for (int u=0; u<V; ++u) { mincost[u] = min(mincost[u], cost[v][u]); } } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> V; using P = pair<int, int>; vector< P > v(V); rep(i, V) { P a; int x, y; cin >> x >> y; a = { x, y }; v[i] = a; } rep(i, V) { for (int j=i+1; j<V; ++j) { cost[i][j] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ); cost[j][i] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ); } } cout << prim() << endl; }
/tmp/ccTzEEHY.o: in function `prim()': a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o a.cc:(.text+0x148): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s824608431
p03684
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i)) using ll = long long; const int MAXV = 100010; const int INF = 1e8; int cost[MAXV][MAXV]; int mincost[MAXV]; bool used[MAXV]; int V; ll prim() { for (int i=0; i<V; ++i) { mincost[i] = INF; used[i] = false; } mincost[0] = 0; ll res = 0; while (true) { int v = -1; for (int u=0;u<V;++u) { if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u; } if (v == -1) break; used[v] = true; res += mincost[v]; for (int u=0; u<V; ++u) { mincost[u] = min(mincost[u], cost[v][u]); } } return res; } int main() { scanf("%d", &V); using P = pair<int, int>; vector< P > v(V); rep(i, V) { P a; int x, y; scanf("%d %d", &x, &y); a = { x, y }; v[i] = a; } rep(i, V) { for (int j=i+1; j<V; ++j) { cost[i][j] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ); cost[j][i] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ); } } cout << prim() << endl; }
/tmp/cccN8ir6.o: in function `prim()': a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o a.cc:(.text+0x148): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s543862927
p03684
C++
#include <bits/stdc++.h> using namespace std; #define int int64_t #define x first #define y second typedef pair <int, int> pi; const int N = 1e5 + 10; int n, u, v, v2, u2, ans, l, r, pa[N], sz[N]; vector <int> g[N]; pi p[N]; vector <pi> xx, yy; struct edge { int u, v, w; }; bool operator < (edge a, edge b) { return a.w < b.w; } vector <edge> e; int root(int v) { return (pa[v] == v) ? v : pa[v] = root(pa[v]); } bool same(int u, int v) { return root(u) == root(v); } void merge(int u, int v) { u = root(u), v = root(v); if (u == v) return; if (sz[u] < sz[v]) swap(u, v); sz[u] += sz[v]; pa[v] = u; } void kruskal() { for (int i = 0; i < n; ++i) pa[i] = i, sz[i] = 1; sort(e.begin(), e.end()); for (auto i: e) { if (!same(i.u, i.v)) { merge(i.u, i.v); ans += i.w; } } } int f(int i, int j) { return min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y)); } void make_graph() { for (int i = 0; i < n; ++i) { l = max(i - 3, 0ll), r = min(i + 3, n); v = xx[i].y; v2 = yy[i].y; for (int j = l; j < r; ++j) { u = xx[j].y; u2 = yy[j].y; if (v < u) e.push_back({v, u, f(v, u)}); if (v2 < u2) e.push_back({v2, u2, f(v2, u2)}); } } } main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> p[i].x >> p[i].y; xx.push_back({p[i].x, i}); yy.push_back({p[i].y, i}); } sort(xx.begin(), xx.end()); sort(yy.begin(), yy.end()); make_graph(); kruskal(); cout << ans << '\n'; return 0; }
a.cc: In function 'void make_graph()': a.cc:50:16: error: no matching function for call to 'max(int64_t, long long int)' 50 | l = max(i - 3, 0ll), r = min(i + 3, n); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:50:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 50 | l = max(i - 3, 0ll), r = min(i + 3, n); | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:50:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 50 | l = max(i - 3, 0ll), r = min(i + 3, n); | ~~~^~~~~~~~~~~~ a.cc: At global scope: a.cc:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 64 | main() { | ^~~~
s598255479
p03684
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL maxn=100500,inf=LONG_LONG_MAX; LL x[maxn],y[maxn],Map[maxn][maxn],vis[maxn],ans,n,d[maxn]; struct node { LL v,len;//v代表当前顶点,w代表v到答案集合的最小距离 friend bool operator <(node a,node b) { return a.len>b.len; } }; LL prim() { priority_queue<node>q; node t; t.v=1;t.len=0; q.push(t);//初始化顶点1到答案集合的距离为0,以保证第一次一定选入顶点1到答案集合中去 ans=0; fill(vis,vis+maxn,0); fill(d,d+maxn,inf); while(q.size()) { t=q.top();q.pop();//取离答案集合距离最小的顶点 if(vis[t.v]) continue;//如果已经在答案集合中则进行下一次的循环 vis[t.v]=1;//否则取顶点t.v加入到答案集合中 ans+=t.len; for(int i=1;i<=n;i++)//更新未加入答案集合的顶点到答案集合 的距离 { if(!vis[i]&&Map[t.v][i]<d[i])//可以更新则入队 { node next; next.v=i; next.len=Map[t.v][i]; d[i]=Map[t.v][i]; q.push(next); } } } return ans; } int main() { cin.sync_with_stdio(0); while(cin>>n) { for(int i=1;i<=n;i++) cin>>x[i]>>y[i]; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) Map[i][j]=min(abs(x[i]-x[j]),abs(y[i]-y[j])); cout<<prim()<<endl; } return 0; }
/tmp/ccTmBal4.o: in function `prim()': a.cc:(.text+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x5e): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x123): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o a.cc:(.text+0x16a): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s584568661
p03684
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i)) using ll = long long; struct UnionFind { static const int Max = 100010; int par[Max]; int rank[Max]; void init(int n) { for (int i = 0; i < n; ++i) { par[i] = i; rank[i] = 0; } } int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } }; const ll MAXE = (1e5 * (1e5 - 1) / 2) + 1; struct edge { int u, v; ll cost; }; bool comp(const edge& e1, const edge& e2) { return e1.cost < e2.cost; } edge es[MAXE]; int V, E; ll kruskal() { sort(es, es+E, comp); UnionFind uf; uf.init(V); ll res = 0; for (int i=0; i<E; ++i) { edge e = es[i]; if (!uf.same(e.u, e.v)) { uf.unite(e.u, e.v); res += e.cost; } } return res; } int main() { cin >> V; using P = pair<int, int>; vector< P > v(V); rep(i, V) { P a; int x, y; cin >> x >> y; a = { x, y }; v[i] = a; } rep(i, V) { for (int j=i+1; j<V; ++j) { edge e = {i, j, min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ) }; es[E++] = e; } } cout << kruskal() << endl; }
/tmp/ccK28nWJ.o: in function `kruskal()': a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x63): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o /tmp/ccK28nWJ.o: in function `main': a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x2d5): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x300): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o a.cc:(.text+0x313): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o collect2: error: ld returned 1 exit status
s516440091
p03684
C++
#include<cstdio> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; const int MAXN = 100010; int n, en, fa[MAXN]; struct Point { int x, y, id; }P[MAXN]; struct Edge { int from, to, w; Edge(int from = 0, int to = 0, int w = 0) : from(from), to(to), w(w) {} bool operator < (const Edge &rhs) const { return w < rhs.w; } }E[MAXN<<1]; ll ans; bool cmp1(Point a, Point b) { return a.x < b.x; } bool cmp2(Point a, Point b) { return a.y < b.y; } inline int dis(int a, int b) { return min(abs(P[a].x-P[b].x), abs(P[a].y-P[b].y)); } inline int read() { int x = 0, f = 1; char ch = getchar(); for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1; for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48); return x * f; } int find(int x) { return fa[x] = fa[x] == x ? x : find(fa[x]); } int main() { int i; n = read(); for(i = 1; i <= n; i++) P[i].x = read(), P[i].y = read(), P[i].id = i; sort(P+1, P+n+1, cmp1); for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1)); sort(P+1, P+n+1, cmp2); for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1)); sort(E+1, E+en+1); for(i = 1; i <= n; i++) fa[i] = i; for(i = 1; i <= en; i++) { int a = E[i].from, b = E[i].to; int x = find(a), y = find(b); if(x == y) continue; fa[x] = y, ans += E[i].w; } printf("%lld\n", ans); return 0; }
a.cc: In function 'int read()': a.cc:36:16: error: 'isdigit' was not declared in this scope 36 | for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1; | ^~~~~~~ a.cc:37:15: error: 'isdigit' was not declared in this scope 37 | for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48); | ^~~~~~~
s085570527
p03684
C++
#include <cstdio> #include <cstring> #include <vector> #include <queue> #include <string> #include <algorithm> #include <iostream> #include <string> #include <map> #include <set> #include <functional> #include <iostream> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> PP; int n; P p[100001]; vector<int> y[100001]; vector<int> xi; vector<P> query; vector<PP> edge; int rank[100001]; int par[100001]; void init(){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } void unite(int x,int y){ x=find(x); y=find(y); if(x==y)return; if(rank[x]<rank[y]){ par[x]=y; }else{ par[y]=x; if(rank[x]==rank[y])rank[x]++; } } bool same(int x,int y){ return find(x)==find(y); } int main(void){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d",&p[i].first,&p[i].second); xi.push_back(p[i].first); } sort(xi.begin(),xi.end()); xi.erase(unique(xi.begin(),xi.end()),xi.end()); sort(p,p+n); for(int i=0;i<n;i++){ p[i].first=lower_bound(xi.begin(),xi.end(),p[i].first)-xi.begin(); query.push_back(P(p[i].second,p[i].first)); } for(int i=0;i<(int)xi.size()-1;i++){ edge.push_back(PP(xi[i+1]-xi[i],P(i,i+1))); } sort(query.begin(),query.end()); for(int i=0;i<(int)query.size()-1;i++){ int f=query[i+1].second; int t=query[i].second; int cost=query[i+1].first-query[i].first; edge.push_back(PP(cost,P(f,t))); } sort(edge.begin(),edge.end()); init(); ll res=0; for(int i=0;i<edge.size();i++){ if(!same(edge[i].second.first,edge[i].second.second)){ unite(edge[i].second.first,edge[i].second.second); res=(ll)res+edge[i].first; } } printf("%lld\n",res); return 0; }
a.cc: In function 'void init()': a.cc:31:17: error: reference to 'rank' is ambiguous 31 | rank[i]=0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/vector:62, from a.cc:3: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:47:12: error: reference to 'rank' is ambiguous 47 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~ a.cc:47:20: error: reference to 'rank' is ambiguous 47 | if(rank[x]<rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~ a.cc:51:20: error: reference to 'rank' is ambiguous 51 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~ a.cc:51:29: error: reference to 'rank' is ambiguous 51 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~ a.cc:51:37: error: reference to 'rank' is ambiguous 51 | if(rank[x]==rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:25:5: note: 'int rank [100001]' 25 | int rank[100001]; | ^~~~
s470080710
p03684
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; vector<pair<int,pair<int,int> > >G; int parent[1<<17],rank[1<<17]; pair<int,int>x[1<<17],y[1<<17]; int find(int a) { return a!=parent[a]?parent[a]=find(parent[a]):a; } int unite(int a,int b) { int pa=find(a),pb=find(b); if(rank[pa]<rank[pb]) { parent[pb]=pa; } else { parent[pa]=pb; if(rank[pa]==rank[pb])rank[pb]++; } } main() { int n; cin>>n; for(int i=0;i<n;i++) { parent[i]=i; cin>>x[i].first>>y[i].first; x[i].second=y[i].second=i; } sort(x,x+n); sort(y,y+n); for(int i=0;i<n-1;i++) { G.push_back(make_pair(abs(x[i+1].first-x[i].first),make_pair(x[i].second,x[i+1].second))); G.push_back(make_pair(abs(y[i+1].first-y[i].first),make_pair(y[i].second,y[i+1].second))); } sort(G.begin(),G.end()); long ans=0; for(int i=0;i<G.size();i++) { int nx=G[i].second.first,ny=G[i].second.second,cost=G[i].first; int px=find(nx),py=find(ny); if(px==py)continue; else { ans+=cost; unite(px,py); } } cout<<ans<<endl; }
a.cc: In function 'int unite(int, int)': a.cc:15:12: error: reference to 'rank' is ambiguous 15 | if(rank[pa]<rank[pb]) | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:19: note: 'int rank [131072]' 6 | int parent[1<<17],rank[1<<17]; | ^~~~ a.cc:15:21: error: reference to 'rank' is ambiguous 15 | if(rank[pa]<rank[pb]) | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:19: note: 'int rank [131072]' 6 | int parent[1<<17],rank[1<<17]; | ^~~~ a.cc:22:20: error: reference to 'rank' is ambiguous 22 | if(rank[pa]==rank[pb])rank[pb]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:19: note: 'int rank [131072]' 6 | int parent[1<<17],rank[1<<17]; | ^~~~ a.cc:22:30: error: reference to 'rank' is ambiguous 22 | if(rank[pa]==rank[pb])rank[pb]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:19: note: 'int rank [131072]' 6 | int parent[1<<17],rank[1<<17]; | ^~~~ a.cc:22:39: error: reference to 'rank' is ambiguous 22 | if(rank[pa]==rank[pb])rank[pb]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:19: note: 'int rank [131072]' 6 | int parent[1<<17],rank[1<<17]; | ^~~~ a.cc:24:1: warning: no return statement in function returning non-void [-Wreturn-type] 24 | } | ^ a.cc: At global scope: a.cc:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 25 | main() | ^~~~
s581793612
p03684
C++
#include <iostream> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include<queue> #include <string> #define N 250000 #define MOD 1000000007 using namespace std; int cas; int n,m; struct ds{int x,y,i;}d[N]; bool cmpx(ds d1,ds d2){return d1.x<d2.x;} bool cmpy(ds d1,ds d2){return d1.y<d2.y;} struct es{int i,j,c;}e[N]; bool cmp(es d1,es d2){return d1.c<d2.c;} int p[N]; int getf(int x) { int i=x,j; while(p[i]!=i)i=p[i]; while(p[x]!=i){j=p[x];p[x]=i;x=j;} return i; } void merge(int a,int b) { a=getf(a);b=getf(b); p[a]=b; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { d[i].i=i; p[i]=i; scanf("%d%d",&d[i].x,&d[i].y); } sort(d+1,d+n+1,cmpx); for(int i=1;i<n;i++) { e[i].i=d[i].i; e[i].j=d[i+1].i; e[i].c=d[i+1].x-d[i].x; } sort(d+1,d+n+1,cmpy); for(int i=1;i<n;i++) { e[i+n-1].i=d[i].i; e[i+n-1].j=d[i+1].i; e[i+n-1].c=d[i+1].y-d[i].y; } sort(e+1,e+2*n-1,cmp); long long ans=0,cnt=0; for(int i=1;i<=2*n-2;i++) { if(getf(e[i].i)!=getf(e[i].j)) { merge(e[i].i,e[i].j); ans+=e[i].c; cnt++; if(cnt==n-1){cout<<ans;return 0;} } } }
a.cc: In function 'int main()': a.cc:40:5: error: 'sort' was not declared in this scope; did you mean 'short'? 40 | sort(d+1,d+n+1,cmpx); | ^~~~ | short
s592265330
p03684
C++
3 1 5 3 9 7 8 6 8 3 4 9 12 19 18 1 13 5 7 6
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s226092801
p03685
C++
#include <iostream> #include <vector> #include <map> #include <stack> using namespace std; int main(){ int R, C, N; cin >> R >> C >> N; vector<int> x1(N), y1(N), x2(N), y2(N); for (int i = 0; i < N; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; } vector<pair<int, int>> pos; for (int i = 0; i < N; i++){ int p = -1; if (x1[i] == 0){ p = y1[i]; } else if (y1[i] == R){ p = R + x1[i]; } else if (x1[i] == C){ p = R + C + R - y1[i]; } else if (y1[i] == 0){ p = R + C + R + C - x1[i]; } int q = -1; if (x2[i] == 0){ q = y2[i]; } else if (y2[i] == R){ q = R + x2[i]; } else if (x2[i] == C){ q = R + C + R - y2[i]; } else if (y2[i] == 0){ q = R + C + R + C - x2[i]; } if (p != -1 && q != -1){ pos.push_back(make_pair(p, i + 1)); pos.push_back(make_pair(q, i + 1)); } } sort(pos.begin(), pos.end()); stack<int> st; st.push(-1); for (auto P : pos){ if (st.top() == P.second){ st.pop(); } else { st.push(P.second); } } if (st.size() == 1){ cout << "YES" << endl; } else { cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:40:9: error: 'sort' was not declared in this scope; did you mean 'short'? 40 | sort(pos.begin(), pos.end()); | ^~~~ | short
s637239789
p03685
C++
#include <iostream> #include <vector> #include <map> #include <stack> using namespace std; int main(){ int R, C, N; cin >> R >> C >> N; vector<int> x1(N), y1(N), x2(N), y2(N); for (int i = 0; i < N; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; } map<int, int> pos; for (int i = 0; i < N; i++){ int p = -1; if (x1[i] == 0){ p = y1[i]; } else if (y1[i] == R){ p = R + x1[i]; } else if (x1[i] == C){ p = R + C + R - y1[i]; } else if (y1[i] == 0){ p = R + C + R + C - x1[i]; } int q = -1; if (x2[i] == 0){ q = y2[i]; } else if (y2[i] == R){ q = R + x2[i]; } else if (x2[i] == C){ q = R + C + R - y2[i]; } else if (y2[i] == 0){ q = R + C + R + C - x2[i]; } if (p != -1 && q != -1){ if (p > q){ swap(p, q); } assert(!pos.count(p)); assert(!pos.count(q)); pos[p] = i + 1; pos[q] = - (i + 1); } } stack<int> st; for (auto P : pos){ if (!st.empty()){ if (st.top() == - P.second){ st.pop(); } else { st.push(P.second); } } else { st.push(P.second); } } if (st.empty()){ cout << "YES" << endl; } else { cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:39:25: error: 'assert' was not declared in this scope 39 | assert(!pos.count(p)); | ^~~~~~ a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 4 | #include <stack> +++ |+#include <cassert> 5 | using namespace std;
s602605664
p03685
C++
#include <iostream> #include <vector> #include <map> #include <stack> #include <cassert> using namespace std; int main(){ int R, C, N; cin >> R >> C >> N; vector<int> x1(N), y1(N), x2(N), y2(N); for (int i = 0; i < N; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; } map<int, int> pos; for (int i = 0; i < N; i++){ int p = -1; if (x1[i] == 0){ p = y1[i]; } else if (y1[i] == R){ p = R + x1[i]; } else if (x1[i] == C){ p = R + C + R - y1[i]; } else if (y1[i] == 0){ p = R + C + R + C - x1[i]; } int q = -1; if (x2[i] == 0){ q = y2[i]; } else if (y2[i] == R){ q = R + x2[i]; } else if (x2[i] == C){ q = R + C + R - y2[i]; } else if (y2[i] == 0){ q = R + C + R + C - x2[i]; } if (p != -1 && q != -1){ if (p > q){ swap(p, q); } assert(!pos.count(p)); assert(!pos.count(q)); pos[p] = i + 1; pos[q] = - (i + 1); } } vector<int> P; for (int x : pos){ P.push_back(x.second); } bool ok = true; stack<int> st; for (auto x : P){ if (x > 0){ st.push(x); } else { if (st.top() + x == 0){ st.pop(); } else { ok = false; break; } } } if (ok){ cout << "YES" << endl; } else { cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:47:22: error: cannot convert 'std::pair<const int, int>' to 'int' in initialization 47 | for (int x : pos){ | ^~~ a.cc:48:31: error: request for member 'second' in 'x', which is of non-class type 'int' 48 | P.push_back(x.second); | ^~~~~~
s462584022
p03685
C++
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define DEBUG #ifdef DEBUG #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " = " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || "; __f(comma+1, args...); } #else #define debug(...) #endif template <class Ch, class Tr, class Container> basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) { os << "{ "; for(auto& y : x) os << y << " ; "; return os << "}"; } template <class X, class Y> ostream & operator << (ostream & os, pair <X, Y> const& p) { return os << "[ " << p.first << ", " << p.second << "]" ; } #define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define ll long long int #define pb push_back #define mp make_pair #define ld long double #define sz(a) (ll)(a).size() #define endl "\n" // priority_queue<ll, vector<ll>, less<ll>>pq; // Max Heap // priority_queue<ll, vector<ll>, greater<ll>>pq; // Min Heap typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; //K-th smallest //cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl; //NO OF ELEMENTS < X //cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl; map<pair<ll,ll>, ll>val; map<ll, ll>cnt, isboundary; int main() { FAST_IO; ll r, c, n; cin >> r >> c >> n; for(int i=0;i<n;i++) { ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; val[{x1, y1}] = i + 1; val[{x2, y2}] = i + 1; if(x1 == 0 || x1 == r || y1 == 0 || y1 == c) isboundary[i + 1] += 1; if(x2 == 0 || x2 == r || y2 == 0 || y2 == c) isboundary[i + 1] += 1; } stack<ll>s; for(int i=0;i<=c;i++) { if(isboundary[val[{0, i}]] != 2) continue; if(cnt[val[{0, i}]] == 1) { if(s.top() != val[{0, i}]) { cout << "NO" << endl; return 0; } else s.pop(); } else { s.push(val[{0, i}]); cnt[val[{0, i}]] += 1; } } for(int i=1;i<=r;i++) { if(isboundary[val[{i, c}]] != 2) continue; if(cnt[val[{i, c}]] == 1) { if(s.top() != val[{i, c}]) { cout << "NO" << endl; return 0; } else s.pop(); } else { s.push(val[{i, c}]); cnt[val[{i, c}]] += 1; } } for(int i=c - 1;i>=0;i--) { if(isboundary[val[{r, i}]] != 2) continue; if(cnt[val[{r, i}]] == 1) { if(s.top() != val[{r, i}]) { cout << "NO" << endl; return 0; } else s.pop(); } else { s.push(val[{r, i}]); cnt[val[{r, i}]] += 1; } } for(int i=r - 1;i>=0;i--) { if(isboundary[val[{i, 0}]] != 2) continue; if(cnt[val[{i, 0}]] == 1) { if(s.top() != val[{i, 0}]) { cout << "NO" << endl; return 0; } else s.pop(); } else { s.push(val[{i, 0}]); cnt[val[{i, 0}]] += 1; } } cout << "YES" << endl; return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:5: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, long long int>, std::_Select1st<std::pair<const std::pair<long long int, long long int>, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> > >::_Rb_tree_impl<std::less<std::pair<long long int, long long int> >, true>::~_Rb_tree_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const std::pair<long long int, long long int>, long long int> >]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/map:62, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152: /usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here 658 | struct _Rb_tree_impl | ^~~~~~~~~~~~~
s144769012
p03685
C++
#include <iostream> #include <vector> #include <map> #include <stack> using namespace std; int main(){ int R, C, N; cin >> R >> C >> N; vector<int> x1(N), y1(N), x2(N), y2(N); for (int i = 0; i < N; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; } map<int, int> pos; for (int i = 0; i < N; i++){ int p = -1; if (x1[i] == 0){ p = y1[i]; } else if (y1[i] == R){ p = R + x1[i]; } else if (x1[i] == C){ p = R + C + R - y1[i]; } else if (y1[i] == 0){ p = R + C + R + C - x1[i]; } int q = -1; if (x2[i] == 0){ q = y2[i]; } else if (y2[i] == R){ q = R + x2[i]; } else if (x2[i] == C){ q = R + C + R - y2[i]; } else if (y2[i] == 0){ q = R + C + R + C - x1[i]; } if (p != -1 && q != -1){ if (p > q){ swap(p, q); } pos[p] = i + 1; pos[q] = - (i + 1); } } bool ok = true; stack<int> st; for (auto P : pos){ if (P.second > 0){ st.push(P.second); } else { if (st.top() == - P.second){ st.pop(); } else { ok = false; break; } } } if (ok){ cout << "YES" << endl; } else { assert(false); cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:60:17: error: 'assert' was not declared in this scope 60 | assert(false); | ^~~~~~ a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 4 | #include <stack> +++ |+#include <cassert> 5 | using namespace std;
s174656578
p03685
C++
#include <bits/stdc++.h> using namespace std; int r,c; int sd(pair<int,int> a){ int x,y; tie(x,y) = a; if(x==0) return 0; if(y==c) return 1; if(x==r) return 2; if(y==0) return 3; return -1; } struct cmpar{ bool operator()(const pair<pair<int,int>,int>& a, const pair<pair<int,int>,int>& b){ if(sd(a.first)!=sd(b.first)) return sd(a.first)<sd(b.first); if(sd(a.first)<2) return a.first<b.first; return a.first>b.first; } }bcmp; int main(){ scanf("%d%d",&r,&c); int n; scanf("%d",&n); vector<pair<pair<int,int>,int>> xvec; for(int i = 0; i<n; i++){ int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if(sd({x1,y1})!=-1&&sd({x2,y2})!=-1){ xvec.push_back({{x1,y1},i}); xvec.push_back({{x2,y2},i}); } } sort(xvec.begin(),xvec.end(),bcmp); int xsz = xvec.size(); for(int i = 0; i<xsz; i++) xvec.push_back(xvec[i]); xsz+=xsz; stack<int> ist; vector<int> xc(n,0); bool failed = false; for(int i = 0;i<xsz; i++){ if(!ist.empty()&&ist.top()==xvec[i].second){ xc[xvec[i].second]--; ist.pop(); }else if(!xc[xvec[i].second]){ xc[xvec[i].second]++; ist.push(xvec[i].second); }else{ failed = true; break; } } if(failed) printf("NO\n"); else printf("YES\n"); return 0; }
a.cc:29:2: error: 'cmpar bcmp' redeclared as different kind of entity 29 | }bcmp; | ^~~~ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:34:12: note: previous declaration 'int bcmp(const void*, const void*, size_t)' 34 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = int (*)(const void*, const void*, long unsigned int) noexcept]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = int (*)(const void*, const void*, long unsigned int) noexcept]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:44:9: required from here 44 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'std::pair<std::pair<int, int>, int>' to 'const void*' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<std::pair<int, int>, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = int (*)(const void*, const void*, long unsigned int) noexcept]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = int (*)(const void*, const void*, long unsigned int) noexcept]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:44:9: required from here 44 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'std::pair<std::pair<int, int>, int>' to 'const void*' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Value = std::pair<std::pair<int, int>, int>; _Compare = int (*)(const void*, const void*, long unsigned int) noexcept]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Distance = long int; _Tp = pair<pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<int (*)(const void*, const void*, long unsigned int) noexcept>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Distance = long int; _Tp = pair<pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(const void*, const void*, long unsigned int) noexcept>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(c
s725868870
p03685
C++
#include <bits/stdc++.h> using namespace std; int r,c; int sd(pair<int,int> a){ int x,y; tie(x,y) = a; if(x==0) return 0; if(y==c) return 1; if(x==r) return 2; if(y==0) return 3; return -1; } bool bcmp(const pair<pair<int,int>,int>& a, const pair<pair<int,int>,int>& b){ if(sd(a.first)!=sd(b.first)) return sd(a.first)<sd(b.first); if(sd(a.first)<2) return a.first<b.first; return a.first>b.first; } int main(){ scanf("%d%d",&r,&c); int n; scanf("%d",&n); vector<pair<pair<int,int>,int>> xvec; for(int i = 0; i<n; i++){ int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if(sd({x1,y1})!=-1&&sd({x2,y2})!=-1){ xvec.push_back({{x1,y1},i}); xvec.push_back({{x2,y2},i}); } } sort(xvec.begin(),xvec.end(),bcmp); int xsz = xvec.size(); for(int i = 0; i<xsz; i++) xvec.push_back(xvec[i]); xsz+=xsz; stack<int> ist; vector<int> xc(n,0); bool failed = false; for(int i = 0;i<xsz; i++){ if(!ist.empty()&&ist.top()==xvec[i].second){ xc[xvec[i].second]--; ist.pop(); }else if(!xc[xvec[i].second]){ xc[xvec[i].second]++; ist.push(xvec[i].second); }else{ failed = true; break; } } if(failed) printf("NO\n"); else printf("YES\n"); return 0; }
a.cc: In function 'int main()': a.cc:42:9: error: no matching function for call to 'sort(std::vector<std::pair<std::pair<int, int>, int> >::iterator, std::vector<std::pair<std::pair<int, int>, int> >::iterator, <unresolved overloaded function type>)' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)' 4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate expects 2 arguments, 3 provided /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' 4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: template argument deduction/substitution failed: a.cc:42:9: note: couldn't deduce template parameter '_Compare' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)' 292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 3 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)' 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15: /usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Tp = void]': /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >]' a.cc:42:9: required from here 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>' 82 | using __enable_if_execution_policy = | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s140218160
p03685
C++
#include <bits/stdc++.h> using namespace std; int r,c; int sd(pair<int,int> a){ int x,y; tie(x,y) = a; if(x==0) return 0; if(y==c) return 1; if(x==r) return 2; if(y==0) return 3; return -1; } bool bcmp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){ if(sd(a.first)!=sd(b.first)) return sd(a.first)<sd(b.first); if(sd(a.first)<2) return a.first<b.first; return a.first>b.first; } int main(){ scanf("%d%d",&r,&c); int n; scanf("%d",&n); vector<pair<pair<int,int>,int>> xvec; for(int i = 0; i<n; i++){ int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if(sd({x1,y1})!=-1&&sd({x2,y2})!=-1){ xvec.push_back({{x1,y1},i}); xvec.push_back({{x2,y2},i}); } } sort(xvec.begin(),xvec.end(),bcmp); int xsz = xvec.size(); for(int i = 0; i<xsz; i++) xvec.push_back(xvec[i]); xsz+=xsz; stack<int> ist; vector<int> xc(n,0); bool failed = false; for(int i = 0;i<xsz; i++){ if(!ist.empty()&&ist.top()==xvec[i].second){ xc[xvec[i].second]--; ist.pop(); }else if(!xc[xvec[i].second]){ xc[xvec[i].second]++; ist.push(xvec[i].second); }else{ failed = true; break; } } if(failed) printf("NO\n"); else printf("YES\n"); return 0; }
a.cc: In function 'int main()': a.cc:42:9: error: no matching function for call to 'sort(std::vector<std::pair<std::pair<int, int>, int> >::iterator, std::vector<std::pair<std::pair<int, int>, int> >::iterator, <unresolved overloaded function type>)' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)' 4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate expects 2 arguments, 3 provided /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' 4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: template argument deduction/substitution failed: a.cc:42:9: note: couldn't deduce template parameter '_Compare' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)' 292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 3 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)' 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15: /usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Tp = void]': /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >]' a.cc:42:9: required from here 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>' 82 | using __enable_if_execution_policy = | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s536975476
p03685
C++
#include<bits/stdc++.h> #define lld long long int #define ld long double #define mod 1000000007 #define modd 998244353 #define all(v) v.begin(),v.end() #define rep(i,a,b) for(lld i=a;i<=b;i++) #define repr(i,a,b) for(lld i=a;i>=b;i--) #define ar array #define pb push_back #define mp make_pair #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; lld n,m,r,c; lld arr[300000]; vector<ar<lld,3> >bor; bool comp(ar<lld,3> a,ar<lld,3> b){ if (a[0]==b[0]){ if (a[0]){ return a[1]>b[1]; } else { return a[1]<b[1]; } } else { if (a[1]==b[1]){ if (a[1]){ return a[0]<b[0]; } else { return a[0]>b[0]; } } else { if (a[0]==0) return true; if (a[1]==0) return false; if (a[0]==r) { if (b[1]==0) return true; else return false; } if (b[1]==0||b[0]==r)return true; return false; } } } int main() { ios; lld TESTS,q,a,s,b,l,k,p,h,w,d,x,y,z,xs,ys,t; TESTS=1; // cin>>TESTS; while(TESTS--) { cin>>r>>c>>n; lld ans=0; //bool pos1=false,pos2=false; rep(i,0,n-1){ cin>>x>>y>>a>>b; if (((x==0||x==r)&&(y==0||y==r))&&((a==0||a=r)&&(b==0||b==r))){ bor.pb({x,y,i}); bor.pb({a,b,i}); } } bool pos=true; sort(all(bor),comp); m=bor.size(); rep(i,0,m/2-1) if (bor[i][2]!=bor[m-1-i][2])pos=false; (pos)?cout<<"YES":cout<<"NO"; } return 0; }
a.cc: In function 'int main()': a.cc:60:53: error: lvalue required as left operand of assignment 60 | if (((x==0||x==r)&&(y==0||y==r))&&((a==0||a=r)&&(b==0||b==r))){ | ~~~~^~~
s590875545
p03685
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; #define i_7 (long long)(1e9+7) //#define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } long long po(long a, long b){ if(b==0){ return 1; } long long z = po(a,b/2); z = mod(z*z); if(b%2!=0){ z = mod(a*z); } return z; } bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=std::sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ std::swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } //using namespace std; //using namespace boost::multiprecision; int main(){ using namespace std; int r,c,n; cin>>r>>c>>n; int x[n][2], y[n][2]; REP(i,n){ cin>>x[i][0]>>y[i][0]>>x[i][1]>>y[i][1]; } typedef pair<int, int> P; vector<pair<P, int>> ue, re, de, le; REP(i,n){ if(x[i][0] == 0 && x[i][1] == r){ ue.push_back(make_pair(P(x[i][1], y[i][1]), i)); de.push_back(make_pair(P(x[i][0], y[i][0]), i)); }else if(x[i][0] == r && x[i][1] == 0){ ue.push_back(make_pair(P(x[i][0], y[i][0]), i)); de.push_back(make_pair(P(x[i][1], y[i][1]), i)); }else if(y[i][0] == 0 && y[i][1] == c){ le.push_back(make_pair(P(x[i][0], y[i][0]), i)); re.push_back(make_pair(P(x[i][1], y[i][1]), i)); }else if(y[i][0] == c && y[i][1] == 0){ le.push_back(make_pair(P(x[i][1], y[i][1]), i)); re.push_back(make_pair(P(x[i][0], y[i][0]), i)); }else{ continue; } } sort(ALL(ue)); sort(ALL(re), greater<pair<int, P>>()); sort(ALL(de), greater<pair<int, P>>()); sort(ALL(le)); stack<int> st; for(auto p:ue){ int now = st.top(); if(now == p.second){ st.pop(); }else{ st.push(p.second); } } for(auto p:re){ int now = st.top(); if(now == p.second){ st.pop(); }else{ st.push(p.second); } } for(auto p:de){ int now = st.top(); if(now == p.second){ st.pop(); }else{ st.push(p.second); } } for(auto p:le){ int now = st.top(); if(now == p.second){ st.pop(); }else{ st.push(p.second); } } if(st.size() == 0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = greater<pair<int, pair<int, int> > >]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:94:7: required from here 94 | sort(ALL(re), greater<pair<int, P>>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<std::pair<int, std::pair<int, int> > >) (std::pair<std::pair<int, int>, int>&, std::pair<std::pair<int, int>, int>&)' 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::pair<int, std::pair<int, int> >]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'const std::pair<int, std::pair<int, int> >&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<std::pair<int, int>, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<pair<int, pair<int, int> > > >]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = greater<pair<int, pair<int, int> > >]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:94:7: required from here 94 | sort(ALL(re), greater<pair<int, P>>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<std::pair<int, std::pair<int, int> > >) (std::pair<std::pair<int, int>, int>&, std::pair<std::pair<int, int>, int>&)' 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::pair<int, std::pair<int, int> >]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'const std::pair<int, std::pair<int, int> >&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Value = std::pair<std::pair<int, int>, int>; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Distance = long int; _Tp = pair<pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<pair<int, pair<int, int> > > >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Distance = long int; _Tp = pair<pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_i
s899195769
p03685
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; #define i_7 (long long)(1e9+7) //#define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } long long po(long a, long b){ if(b==0){ return 1; } long long z = po(a,b/2); z = mod(z*z); if(b%2!=0){ z = mod(a*z); } return z; } bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=std::sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ std::swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } //using namespace std; //using namespace boost::multiprecision; int main(){ using namespace std; int r,c,n; cin>>r>>c>>n; int x[n][2], y[n][2]; REP(i,n){ cin>>x[i][0]>>y[i][0]>>x[i][1]>>y[i][1]; } typedef pair<int, int> P; vector<pair<P, int>> ue, re, de, le; REP(i,n){ if(x[i][0] == 0 && x[i][1] == r){ ue.push_back(make_pair(P(x[i][1], y[i][1]), i)); de.push_back(make_pair(P(x[i][0], y[i][0]), i)); }else if(x[i][0] == r && x[i][1] == 0){ ue.push_back(make_pair(P(x[i][0], y[i][0]), i)); de.push_back(make_pair(P(x[i][1], y[i][1]), i)); }else if(y[i][0] == 0 && y[i][1] == c){ le.push_back(make_pair(P(x[i][0], y[i][0]), i)); re.push_back(make_pair(P(x[i][1], y[i][1]), i)); }else if(y[i][0] == c && y[i][1] == 0){ le.push_back(make_pair(P(x[i][1], y[i][1]), i)); re.push_back(make_pair(P(x[i][0], y[i][0]), i)); }else{ continue; } } sort(ALL(ue)); sort(ALL(re), greater<pair<int, P>>()); sort(ALL(de), greater<pair<int, P>>()); sort(ALL(le)); stack<int> st; for(auto p:ue){ int now = st.top(); if(now == p.second.second){ st.pop(); }else{ st.push(p.second.second); } } for(auto p:re){ int now = st.top(); if(now == p.second.second){ st.pop(); }else{ st.push(p.second.second); } } for(auto p:de){ int now = st.top(); if(now == p.second.second){ st.pop(); }else{ st.push(p.second.second); } } for(auto p:le){ int now = st.top(); if(now == p.second.second){ st.pop(); }else{ st.push(p.second.second); } } if(st.size() == 0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:100:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 100 | if(now == p.second.second){ | ^~~~~~ a.cc:103:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 103 | st.push(p.second.second); | ^~~~~~ a.cc:108:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 108 | if(now == p.second.second){ | ^~~~~~ a.cc:111:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 111 | st.push(p.second.second); | ^~~~~~ a.cc:116:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 116 | if(now == p.second.second){ | ^~~~~~ a.cc:119:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 119 | st.push(p.second.second); | ^~~~~~ a.cc:124:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 124 | if(now == p.second.second){ | ^~~~~~ a.cc:127:24: error: request for member 'second' in 'p.std::pair<std::pair<int, int>, int>::second', which is of non-class type 'int' 127 | st.push(p.second.second); | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = greater<pair<int, pair<int, int> > >]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:94:7: required from here 94 | sort(ALL(re), greater<pair<int, P>>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<std::pair<int, std::pair<int, int> > >) (std::pair<std::pair<int, int>, int>&, std::pair<std::pair<int, int>, int>&)' 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::pair<int, std::pair<int, int> >]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'const std::pair<int, std::pair<int, int> >&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<std::pair<int, int>, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<pair<int, pair<int, int> > > >]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<pair<int, pair<int, int> > > >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Compare = greater<pair<int, pair<int, int> > >]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:94:7: required from here 94 | sort(ALL(re), greater<pair<int, P>>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<std::pair<int, std::pair<int, int> > >) (std::pair<std::pair<int, int>, int>&, std::pair<std::pair<int, int>, int>&)' 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::pair<int, std::pair<int, int> >]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'const std::pair<int, std::pair<int, int> >&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Value = std::pair<std::pair<int, int>, int>; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<pair<int, int>, int>*, vector<pair<pair<int, int>, int> > >; _Distance = long int; _Tp = pair<pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter
s122535355
p03685
C++
#include <bits/stdc++.h> #include "../lib/lazysegmenttree/lazy_segtree_add_sum.hpp" using namespace std; #define SZ(x) (int)(x.size()) using ll = long long; using ld = long double; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vector<int>>; using vll = vector<ll>; using vvll = vector<vector<ll>>; const double eps = 1e-10; const int MOD = 1000000007; const int INF = 1000000000; const ll LINF = 1ll<<50; template<typename T> void printv(const vector<T>& s) { for(int i=0;i<(int)(s.size());++i) { cout << s[i]; if(i == (int)(s.size())-1) cout << endl; else cout << " "; } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int r, c, n; cin >> r >> c >> n; LazySegmentTreeAddSum st(vi((r+c)*2)); bool ok = true; for(int i=0;i<n;++i) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if((x1 == 0 || x1 == r || y1 == 0 || y1 == c) && (x2 == 0 || x2 == r || y2 == 0 || y2 == c)) { int tmp1 = 0, tmp2 = 0; int res1 = 0, res2 = 0; if(y1 == 0) { res1 = st.getsum(x1, x1+1); tmp1 = x1; } else if(x1 == r) { res1 = st.getsum(r+y1, r+y1+1); tmp1 = r + y1; } else if(y1 == c) { res1 = st.getsum(r + c + r - x1, r + c + r - x1 + 1); tmp1 = r + c + r - x1; } else { res1 = st.getsum(r + c + r + c - y1, r + c + r + c - y1 + 1); tmp1 = r + c + r + c - y1; } if(y2 == 0) { res2 = st.getsum(x2, x2 + 1); tmp2 = x2; } else if(x2 == r) { res2 = st.getsum(r + y2, r + y2 + 1); tmp2 = r + y2; } else if(y2 == c) { res2 = st.getsum(r + c + r - x2, r + c + r - x2 + 1); tmp2 = r + c + r - x2; } else { res2 = st.getsum(r + c + r + c - y2, r + c + r + c - y2 + 1); tmp2 = r + c + r + c - y2; } if(res1 != res2) { ok = false; } st.add(min(tmp1, tmp2), max(tmp1, tmp2), 1); } } cout << (ok ? "YES" : "NO") << endl; }
a.cc:2:10: fatal error: ../lib/lazysegmenttree/lazy_segtree_add_sum.hpp: No such file or directory 2 | #include "../lib/lazysegmenttree/lazy_segtree_add_sum.hpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s851492362
p03685
C++
#define _USE_MATH_DEFINES #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <set> #include <map> #include <stack> #include <functional> #include <cassert> #include <cmath> #include <string> using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair<ll, ll> P; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2; //template end int r,c,n; int calc(int x,int y){ if(y==0)return x; else if(x==r)return r+y; else if(y==c)return r+c+r-x; else if(x==0)return r+c+r+c-y; else return -1; } int main(){ int n; scanf("%d%d%d",&r,&c,&n); vector<P> idx; rep(i,0,n){ int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); int f1=calc(x1,y1),f2=calc(x2,y2); if(f1==-1||f2==-1)continue; idx.push_back({f1,i}); idx.push_back({f2,i}); } sort(ALL(idx)); vector<int> st; //stack rep(i,0,idx.size()){ int val=idx[i].second; if(st.size()&&st.back()==val)st.pop_back(); else st.push_back(val); } printf(st.size()?"NO":"YES"); return 0; }
a.cc:25:17: error: 'INT_MAX' was not declared in this scope 25 | const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2; | ^~~~~~~ a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 14 | #include <string> +++ |+#include <climits> 15 | using namespace std; a.cc:25:45: error: 'LLONG_MAX' was not declared in this scope 25 | const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2; | ^~~~~~~~~ a.cc:25:45: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s702224666
p03685
C++
to be coded
a.cc:1:1: error: 'to' does not name a type; did you mean 'auto'? 1 | to be coded | ^~ | auto
s132853159
p03685
C++
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <string> #include <stack> using ll = long long; #define onWall(x, y) (min({x, r-x, y, c-y}) == 0) using namespace std; using P = pair<int, int>; #define fi first #define se second int main() { int r, c, n; cin >> r >> c >> n; vector<int> wall; P points[200000]; for (int i=0, x1, x2, y1, y2; i<n; i++) { cin >> x1 >> y1 >> x2 >> y2; points[i] = {x1, y1}; points[i+n] = {x2, y2}; if (onWall(x1, y1) && onWall(x2, y2)) { wall.push_back(i); wall.push_back(i+n); } } sort(wall.begin(), wall.end(), [&](int l, int r) { P lp = points[l], rp = points[r]; bool lb = (lp.fi <= lp.se), rb = (rp.fi <= rp.se); if (lb ^ rb) return lb > rb; else return (bool)(lb ^ lp > rp); }); stack<int> st; for (auto w:wall) { assert(w < 10000000); int r = w % n; if (!st.empty() && r == st.top()) st.pop(); else st.push(r); } cout << (st.empty() ? "YES" : "NO") << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:40:9: error: 'assert' was not declared in this scope 40 | assert(w < 10000000); | ^~~~~~ a.cc:7:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 6 | #include <stack> +++ |+#include <cassert> 7 |
s987902866
p03685
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef vector<int> VI; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() const int mod=1e9+7; int main(){ longdouble r,c;int n;cin>>r>>c>>n; vector<pair<long double,int>> t; int ctr=0; rep(i,n){ long double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2; if((x1!=0&&x1!=c)&&(y1!=0&&y1!=r))continue; if((x2!=0&&x2!=c)&&(y2!=0&&y2!=r))continue; t.push_back(make_pair(atan2(y1-r/2,x1-c/2),ctr*2)); t.push_back(make_pair(atan2(y2-r/2,x2-c/2),ctr*2+1)); ctr++; } sort(all(t)); stack<int> s; rep(i,t.size()){ int sc=t[i].second; int opp=(sc%2?sc+1:sc-1); if(s.empty()||s.top()!=opp){ s.push(sc); } else{ s.pop(); } } cout<<(s.size()?"NO":"YES")<<endl; }
a.cc: In function 'int main()': a.cc:17:3: error: 'longdouble' was not declared in this scope; did you mean 'double'? 17 | longdouble r,c;int n;cin>>r>>c>>n; | ^~~~~~~~~~ | double a.cc:17:29: error: 'r' was not declared in this scope 17 | longdouble r,c;int n;cin>>r>>c>>n; | ^ a.cc:17:32: error: 'c' was not declared in this scope 17 | longdouble r,c;int n;cin>>r>>c>>n; | ^
s342989596
p03685
C++
#include <bits/stdc++.h> using namespace std; struct ios { static const int IN_LEN = 1 << 18 | 1; char buf[IN_LEN], *s, *t; inline char gc() { return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? 0 : (*s++); } template <typename _tp> inline ios & operator >> (_tp&x) { static char ch; ch = gc(), x = 0; while(ch and !isdigit(ch)) ch = gc(); while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = gc(); return *this; } } io; const int N = 201000; typedef pair<int,int> pii; pii b[N]; int st[N]; int n, R, C, tp, tot; inline int get(int x, int y) { if(x and x != R and y and y != C) return -1; if(y == 0) return x; if(x == R) return R + y; if(y == C) return R + C + (R-x); return R + C + R + (C-y); } int main() { io >> R >> C >> n; for(int i=1,x,y,t1,t2;i<=n;++i) { io >> x >> y, t1 = get(x, y); io >> x >> y, t2 = get(x, y); if(t1 == -1 or t2 == -1) continue; b[++tot] = pii(t1, i); b[++tot] = pii(t2, i); } sort(b+1, b+tot+1); for(int i=1;i<=tot;++i) if(tp and st[tp] == b[i].second) --tp; else st[++tp] = b[i].second; puts(tp ? "NO" : "YES"); return 0; }#include <bits/stdc++.h> using namespace std; struct ios { static const int IN_LEN = 1 << 18 | 1; char buf[IN_LEN], *s, *t; inline char gc() { return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? 0 : (*s++); } template <typename _tp> inline ios & operator >> (_tp&x) { static char ch; ch = gc(), x = 0; while(ch and !isdigit(ch)) ch = gc(); while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = gc(); return *this; } } io; const int N = 201000; typedef pair<int,int> pii; pii b[N]; int st[N]; int n, R, C, tp, tot; inline int get(int x, int y) { if(x and x != R and y and y != C) return -1; if(y == 0) return x; if(x == R) return R + y; if(y == C) return R + C + (R-x); return R + C + R + (C-y); } int main() { io >> R >> C >> n; for(int i=1,x,y,t1,t2;i<=n;++i) { io >> x >> y, t1 = get(x, y); io >> x >> y, t2 = get(x, y); if(t1 == -1 or t2 == -1) continue; b[++tot] = pii(t1, i); b[++tot] = pii(t2, i); } sort(b+1, b+tot+1); for(int i=1;i<=tot;++i) if(tp and st[tp] == b[i].second) --tp; else st[++tp] = b[i].second; puts(tp ? "NO" : "YES"); return 0; }
a.cc:46:2: error: stray '#' in program 46 | }#include <bits/stdc++.h> | ^ a.cc:46:3: error: 'include' does not name a type 46 | }#include <bits/stdc++.h> | ^~~~~~~ a.cc:49:8: error: redefinition of 'struct ios' 49 | struct ios { | ^~~ a.cc:4:8: note: previous definition of 'struct ios' 4 | struct ios { | ^~~ a.cc:61:3: error: conflicting declaration 'int io' 61 | } io; | ^~ a.cc:16:3: note: previous declaration as 'ios io' 16 | } io; | ^~ a.cc:63:11: error: redefinition of 'const int N' 63 | const int N = 201000; | ^ a.cc:18:11: note: 'const int N' previously defined here 18 | const int N = 201000; | ^ a.cc:65:5: error: redefinition of 'pii b [201000]' 65 | pii b[N]; int st[N]; | ^ a.cc:20:5: note: 'pii b [201000]' previously defined here 20 | pii b[N]; int st[N]; | ^ a.cc:65:15: error: redefinition of 'int st [201000]' 65 | pii b[N]; int st[N]; | ^~ a.cc:20:15: note: 'int st [201000]' previously declared here 20 | pii b[N]; int st[N]; | ^~ a.cc:66:5: error: redefinition of 'int n' 66 | int n, R, C, tp, tot; | ^ a.cc:21:5: note: 'int n' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:8: error: redefinition of 'int R' 66 | int n, R, C, tp, tot; | ^ a.cc:21:8: note: 'int R' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:11: error: redefinition of 'int C' 66 | int n, R, C, tp, tot; | ^ a.cc:21:11: note: 'int C' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:14: error: redefinition of 'int tp' 66 | int n, R, C, tp, tot; | ^~ a.cc:21:14: note: 'int tp' previously declared here 21 | int n, R, C, tp, tot; | ^~ a.cc:66:18: error: redefinition of 'int tot' 66 | int n, R, C, tp, tot; | ^~~ a.cc:21:18: note: 'int tot' previously declared here 21 | int n, R, C, tp, tot; | ^~~ a.cc:68:12: error: redefinition of 'int get(int, int)' 68 | inline int get(int x, int y) { | ^~~ a.cc:23:12: note: 'int get(int, int)' previously defined here 23 | inline int get(int x, int y) { | ^~~ a.cc:76:5: error: redefinition of 'int main()' 76 | int main() { | ^~~~ a.cc:31:5: note: 'int main()' previously defined here 31 | int main() { | ^~~~
s735764981
p03685
C++
#include <bits/stdc++.h> using namespace std; struct ios { static const int IN_LEN = 1 << 18 | 1; char buf[IN_LEN], *s, *t; inline char gc() { return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? 0 : (*s++); } template <typename _tp> inline ios & operator >> (_tp&x) { static char ch; ch = gc(), x = 0; while(ch and !isdigit(ch)) ch = gc(); while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = gc(); return *this; } } io; const int N = 201000; typedef pair<int,int> pii; pii b[N]; int st[N]; int n, R, C, tp, tot; inline int get(int x, int y) { if(x and x != R and y and y != C) return -1; if(y == 0) return x; if(x == R) return R + y; if(y == C) return R + C + (R-x); return R + C + R + (C-y); } int main() { io >> R >> C >> n; for(int i=1,x,y,t1,t2;i<=n;++i) { io >> x >> y, t1 = get(x, y); io >> x >> y, t2 = get(x, y); if(t1 == -1 or t2 == -1) continue; b[++tot] = pii(t1, i); b[++tot] = pii(t2, i); } sort(b+1, b+tot+1); for(int i=1;i<=tot;++i) if(tp and st[tp] == b[i].second) --tp; else st[++tp] = b[i].second; puts(tp ? "NO" : "YES"); return 0; }#include <bits/stdc++.h> using namespace std; struct ios { static const int IN_LEN = 1 << 18 | 1; char buf[IN_LEN], *s, *t; inline char gc() { return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? 0 : (*s++); } template <typename _tp> inline ios & operator >> (_tp&x) { static char ch; ch = gc(), x = 0; while(ch and !isdigit(ch)) ch = gc(); while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = gc(); return *this; } } io; const int N = 201000; typedef pair<int,int> pii; pii b[N]; int st[N]; int n, R, C, tp, tot; inline int get(int x, int y) { if(x and x != R and y and y != C) return -1; if(y == 0) return x; if(x == R) return R + y; if(y == C) return R + C + (R-x); return R + C + R + (C-y); } int main() { io >> R >> C >> n; for(int i=1,x,y,t1,t2;i<=n;++i) { io >> x >> y, t1 = get(x, y); io >> x >> y, t2 = get(x, y); if(t1 == -1 or t2 == -1) continue; b[++tot] = pii(t1, i); b[++tot] = pii(t2, i); } sort(b+1, b+tot+1); for(int i=1;i<=tot;++i) if(tp and st[tp] == b[i].second) --tp; else st[++tp] = b[i].second; puts(tp ? "NO" : "YES"); return 0; }
a.cc:46:2: error: stray '#' in program 46 | }#include <bits/stdc++.h> | ^ a.cc:46:3: error: 'include' does not name a type 46 | }#include <bits/stdc++.h> | ^~~~~~~ a.cc:49:8: error: redefinition of 'struct ios' 49 | struct ios { | ^~~ a.cc:4:8: note: previous definition of 'struct ios' 4 | struct ios { | ^~~ a.cc:61:3: error: conflicting declaration 'int io' 61 | } io; | ^~ a.cc:16:3: note: previous declaration as 'ios io' 16 | } io; | ^~ a.cc:63:11: error: redefinition of 'const int N' 63 | const int N = 201000; | ^ a.cc:18:11: note: 'const int N' previously defined here 18 | const int N = 201000; | ^ a.cc:65:5: error: redefinition of 'pii b [201000]' 65 | pii b[N]; int st[N]; | ^ a.cc:20:5: note: 'pii b [201000]' previously defined here 20 | pii b[N]; int st[N]; | ^ a.cc:65:15: error: redefinition of 'int st [201000]' 65 | pii b[N]; int st[N]; | ^~ a.cc:20:15: note: 'int st [201000]' previously declared here 20 | pii b[N]; int st[N]; | ^~ a.cc:66:5: error: redefinition of 'int n' 66 | int n, R, C, tp, tot; | ^ a.cc:21:5: note: 'int n' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:8: error: redefinition of 'int R' 66 | int n, R, C, tp, tot; | ^ a.cc:21:8: note: 'int R' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:11: error: redefinition of 'int C' 66 | int n, R, C, tp, tot; | ^ a.cc:21:11: note: 'int C' previously declared here 21 | int n, R, C, tp, tot; | ^ a.cc:66:14: error: redefinition of 'int tp' 66 | int n, R, C, tp, tot; | ^~ a.cc:21:14: note: 'int tp' previously declared here 21 | int n, R, C, tp, tot; | ^~ a.cc:66:18: error: redefinition of 'int tot' 66 | int n, R, C, tp, tot; | ^~~ a.cc:21:18: note: 'int tot' previously declared here 21 | int n, R, C, tp, tot; | ^~~ a.cc:68:12: error: redefinition of 'int get(int, int)' 68 | inline int get(int x, int y) { | ^~~ a.cc:23:12: note: 'int get(int, int)' previously defined here 23 | inline int get(int x, int y) { | ^~~ a.cc:76:5: error: redefinition of 'int main()' 76 | int main() { | ^~~~ a.cc:31:5: note: 'int main()' previously defined here 31 | int main() { | ^~~~
s343607322
p03685
C++
#include "pch.h" #include<iostream> #include<vector> #include<set> #include<queue> #include<map> #include<algorithm> #include<cstring> #include<string> #include<cassert> #include<cmath> #include<climits> #include<iomanip> #include<stack> using namespace std; #define MOD 1000000007 #define REP(i,n) for(int (i)=0;(i)<(n);(i)++) #define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(),(hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } struct Edge {//グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));//最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph & G, ll v, ll t, ll f, vector<bool> & used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge& e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(Graph & G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size())used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } void BellmanFord(Graph& G, ll s, Array& d, Array &negative) {//O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size())d[i] = INF; REP(i, d.size())negative[i] = false; d[s] = 0; REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true)negative[G[i][j].to] = true; } } } } void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|) d.resize(G.size()); REP(i, d.size())d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first)continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } void WarshallFloyd(Graph& G, Matrix& d) { d.resize(G.size()); REP(i, d.size())d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { d[i][i] = 0; } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } class UnionFind { vector<int> data; public: UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; //約数求める //約数 void divisor(ll n, vector<ll>& ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } //nCrとか class Combination { public: Array fact; Array inv; ll mod; ll mod_inv(ll x) { ll n = mod - 2; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; ll gcd(ll m, ll n) { if (n == 0)return m; return gcd(n, m % n); }//gcd ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } int main() { ll r, c, n; cin >> r >> c >> n; map<ll, ll> ma; REP(i, n) { ll x, y, x2, y2; cin >> x >> y >> x2 >> y2; if ((x == 0 || y == 0 || x == r || y == c)&&(x2 == 0 || y2 == 0 || x2 == r || y2 == c)) { if (y == 0) { ma[x] = i; } else if (x == r) { ma[r + y] = i; } else if (y == c) { ma[r*2 + c - x] = i; } else { ma[r * 2 + c * 2 - y] = i; } if (y2 == 0) { ma[x2] = i; } else if (x2 == r) { ma[r + y2] = i; } else if (y2 == c) { ma[r * 2 + c - x2] = i; } else { ma[r * 2 + c * 2 - y2] = i; } } } Array edge; for (auto itr : ma) { edge.push_back(itr.second); } stack<ll> que; REP(i, edge.size()) { if (que.size()!=0&&que.top() == edge[i]) { que.pop(); } else { que.push(edge[i]); } } if (que.size() == 0) { cout << "YES"; } else { cout << "NO"; } return 0; }
a.cc:1:10: fatal error: pch.h: No such file or directory 1 | #include "pch.h" | ^~~~~~~ compilation terminated.
s600637147
p03685
C++
#include<bits/stdc++.h> using namespace std; int main(){ int r,c,n; cin>>r>>c>>n; map<int,int> vec; auto id=[&](int x,int y){ if(x==0) return y+1; if(y==c) return c+2+x; if(x==r) return c+2+r+1+c-y; if(y==0) return c+2+r+1+c+1+r-x; return 0; }; for(int i=0;i<n;i++){ int x0,y0; cin>>x0>>y0; int x1,y1; cin>>x1>>y1; if(id(x0,y0) && id(x1,y1)){ vec[id(x0,y0)]=i; vec[id(x1,y1)]=i; } } stack<int> st; for(auto i:vec){ if(i!=-1){ if(!st.empty() && st.top()==i) st.pop(); else st.push(i); } } cout<<(st.empty() ? "YES" : "NO")<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:13: error: no match for 'operator!=' (operand types are 'std::pair<const int, int>' and 'int') 29 | if(i!=-1){ | ~^~~~ | | | | | int | std::pair<const int, int> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1305 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed: a.cc:29:16: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1473 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed: a.cc:29:16: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1647 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 29 | if(i!=-1){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:29:16: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 29 | if(i!=-1){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 29 | if(i!=-1){ | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::fpos<_StateT>' 29 | if(i!=-1){ | ^ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'const std::allocator<_CharT>' 29 | if(i!=-1){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:29:16: note: 'std::pair<const int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 29 | if(i!=-1){ | ^ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:29:16: not
s804948645
p03685
C++
#ifndef Local #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma comment(linker, "/STACK:1024000000,1024000000") #endif #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define popCnt(x) (__builtin_popcountll(x)) typedef long long Long; typedef long double Double; const Double EPS = 1e-10; bool areEqual(Double x, Double y, Double eps = EPS) { auto diff = abs(x - y); if (diff < eps) return true; if (min(x, y) < eps) return false; return diff / max(x, y) < eps; } bool isZero(Double x, Double eps = EPS) { return abs(x) <= eps; } struct Point { Double x = 0, y = 0; Point(Double x, Double y) : x(x), y(y) { } Point() { } Point operator +(const Point &p) const { return Point { x + p.x, y + p.y }; } Point operator -(const Point &p) const { return Point { x - p.x, y - p.y }; } Point operator *(Double c) const { return Point(x * c, y * c); } Point operator /(Double c) { return Point(x / c, y / c); } bool operator<(const Point &p) const { return areEqual(x, p.x) ? (y < p.y) : (x < p.x); } bool operator>(const Point& p) const { return areEqual(x, p.x) ? (y > p.y) : (x > p.x); } bool operator==(const Point &p) const { return areEqual(x, p.x) && areEqual(y, p.y); } bool operator!=(const Point& p) const { return !(*this == p); } }; Double dot(Point p, Point q) { return p.x * q.x + p.y * q.y; } Double dist2(Point p, Point q) { return dot(p - q, p - q); } Double cross(Point p, Point q) { return p.x * q.y - p.y * q.x; } Point norm(Point x, Double l) { return x * sqrt(l * l / dot(x, x)); } istream &operator>>(istream &is, Point &p) { return is >> p.x >> p.y; } Point RotateCCW90(Point p) { return Point(-p.y, p.x); } Point RotateCCW(Point p, Double t) { return Point(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t)); } // project point c onto line through a and b (assuming a != b) Point ProjectPointLine(Point a, Point b, Point c) { return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a); } // project point c onto line segment through a and b (assuming a != b) Point ProjectPointSegment(Point a, Point b, Point c) { Double r = dot(c - a, b - a), d = dot(b - a, b - a); if (r < 0) return a; if (r > d) return b; return a + (b - a) * r / d; } Point reflectAroundLine(Point p, Point a, Point b) { return ProjectPointLine(p, a, b) * 2 - p; } bool LinesParallel(const Point& a, const Point& b, const Point& c, const Point& d) { return isZero(cross(b - a, c - d)); } bool LinesCollinear(const Point& a, const Point& b, const Point& c, const Point& d) { return LinesParallel(a, b, c, d) && isZero(cross(b - c, a - c)); } // Returns 1 if CW, 0 if collinear, -1 if ACW. int getDirection(const Point& a, const Point& b, const Point& c) { auto value = cross(c - a, b - a); if (isZero(value)) return 0; return 2 * (value > 0) - 1; } // Checks if c lies in the range [a,b]. bool checkInRange(Double a, Double b, Double c, Double eps = EPS) { if (areEqual(a, c)) return true; if (areEqual(b, c)) return true; return a <= c && c <= b; } // Assuming that c already lies on the straight line ab, // returns true if c lies on the segment ab. bool onSegment(const Point& a, const Point& b, const Point& c) { return checkInRange(a.x, b.x, c.x) && checkInRange(a.y, b.y, c.y); } // Determine if a to b intersects with c to d. bool SegmentsIntersect(const Point& a, const Point& b, const Point& c, const Point& d) { // Handles collinear cases. auto d1 = getDirection(c, d, a); auto d2 = getDirection(c, d, b); auto d3 = getDirection(a, b, c); auto d4 = getDirection(a, b, d); // tmp if (LinesCollinear(a, b, c, d) && (onSegment(a, b, c) && onSegment(a, b, d) || onSegment(c, d, a) && onSegment(c, d, b))) { return false; } if (d1 == 0 && onSegment(c, d, a)) return true; if (d2 == 0 && onSegment(c, d, b)) return true; if (d3 == 0 && onSegment(a, b, c)) return true; if (d4 == 0 && onSegment(a, b, d)) return true; if (d1 == 0 || d2 == 0 || d3 == 0 || d4 == 0) return false; return (((d1 > 0) == (d2 < 0)) && ((d3 > 0) == (d4 < 0))); } // ST Line ab intersect ST Line cd assuming unique intersection exists // for line segments, check if segments intersect first Point ComputeLineIntersection(Point a, Point b, Point c, Point d) { b = b - a; d = c - d; c = c - a; return a + b * cross(c, d) / cross(b, d); // cross(b,d) != 0 } typedef array<Point, 2> Segment; struct Event { int x, type, y, id; tuple<int, int, int, int> getTuple() const { return make_tuple(x, type, y, id); } bool operator <(const Event& other) const { return getTuple() < other.getTuple(); } Event(int x, int type, int y_end, int id) : x(x), type(type), y(y_end), id(id) { } }; struct SetComparator { static vector<Segment> segments; bool operator()(int a, int b) const { if (segments[a][0].x == segments[b][0].x) { return segments[a][0].y < segments[b][0].y; } if (segments[a][0].y == segments[a][1].y && segments[b][0].y == segments[b][1].y && segments[a][0].y == segments[b][0].y) { return segments[a][0].x < segments[b][0].x; } if (segments[a][0] > segments[b][0]) { int dir = getDirection(segments[b][0], segments[b][1], segments[a][0]); return dir > 0; } int dir = getDirection(segments[a][0], segments[a][1], segments[b][0]); return dir < 0; } }; vector<Segment> SetComparator::segments; bool noIntersection(const vector<Segment>& segments) { int n = segments.size(); vector<Event> events; for (int i = 0; i < n; ++i) { events.emplace_back(segments[i][0].x, segments[i][0] > segments[i][1], segments[i][0].y, i); events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], segments[i][1].y, i); } sort(events.begin(), events.end()); SetComparator::segments = segments; set<int, SetComparator> st; for (auto& event : events) { if (event.type == 0) { auto nxt = st.upper_bound(event.id); if (nxt != st.end()) { if (SegmentsIntersect(segments[event.id][0], segments[event.id][1], segments[*nxt][0], segments[*nxt][1])) return false; } if (nxt != st.begin()) { --nxt; if (SegmentsIntersect(segments[event.id][0], segments[event.id][1], segments[*nxt][0], segments[*nxt][1])) return false; } st.insert(event.id); } else { st.erase(event.id); auto nxt = st.upper_bound(event.id); if (nxt != st.end() && nxt != st.begin()) { auto before = nxt; --before; if (SegmentsIntersect(segments[*before][0], segments[*before][1], segments[*nxt][0], segments[*nxt][1])) { return false; } } } } return true; } bool onBorder(const Point& p, int r, int c) { return isZero(p.x) || isZero(p.y) || areEqual(p.x, r) || areEqual(p.y, c); } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #ifdef Local freopen("test.in", "r", stdin); #else #define endl '\n' #endif int r, c, n; cin >> r >> c >> n; vector<Segment> segments; while (n--) { Segment seg; cin >> seg[0] >> seg[1]; // sort(seg.begin(), seg.end()); if (onBorder(seg[0], r, c) && onBorder(seg[1], r, c)) { segments.emplace_back(seg); } } sort(segments.begin(), segments.end()); cout << (noIntersection(segments) ? "YES" : "NO") << endl; }
a.cc: In function 'bool noIntersection(const std::vector<std::array<Point, 2> >&)': a.cc:217:58: error: no match for 'operator<=' (operand types are 'const std::array<Point, 2>::value_type' {aka 'const Point'} and 'const std::array<Point, 2>::value_type' {aka 'const Point'}) 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:8: /usr/include/c++/14/bits/regex.h:1154:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1154 | operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1154:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1260:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1260 | operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1260:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1353:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1353 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1353:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1427:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1427 | operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1427:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1521:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1521 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1521:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1599:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1599 | operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1599:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/regex.h:1699:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1699 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1699:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1064:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1064 | operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1064:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::pair<_T1, _T2>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:469:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 469 | operator<=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:469:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::reverse_iterator<_Iterator>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 513 | operator<=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::reverse_iterator<_Iterator>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1704 | operator<=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::move_iterator<_IteratorL>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1767 | operator<=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'const std::array<Point, 2>::value_type' {aka 'const Point'} is not derived from 'const std::move_iterator<_IteratorL>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:717:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 717 | operator<=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:717:5: note: template argument deduction/substitution failed: a.cc:217:74: note: 'Point' is not derived from 'std::basic_string_view<_CharT, _Traits>' 217 | events.emplace_back(segments[i][1].x, segments[i][0] <= segments[i][1], | ^ /usr/include/c++/14/string_view:724:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(basic
s293914971
p03685
C++
#ifndef Local #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma comment(linker, "/STACK:1024000000,1024000000") #endif #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define popCnt(x) (__builtin_popcountll(x)) typedef long long Long; typedef long double Double; const Double EPS = 1e-10; bool areEqual(Double x, Double y, Double eps = EPS) { auto diff = abs(x - y); if (diff < eps) return true; if (min(x, y) < eps) return false; return diff / max(x, y) < eps; } bool isZero(Double x, Double eps = EPS) { return abs(x) <= eps; } struct Point { Double x = 0, y = 0; Point(Double x, Double y) : x(x), y(y) { } Point() { } Point operator +(const Point &p) const { return Point { x + p.x, y + p.y }; } Point operator -(const Point &p) const { return Point { x - p.x, y - p.y }; } Point operator *(Double c) const { return Point(x * c, y * c); } Point operator /(Double c) { return Point(x / c, y / c); } bool operator<(const Point &p) const { return areEqual(x, p.x) ? (y < p.y) : (x < p.x); } bool operator>(const Point& p) const { return areEqual(x, p.x) ? (y > p.y) : (x > p.x); } bool operator==(const Point &p) const { return areEqual(x, p.x) && areEqual(y, p.y); } bool operator!=(const Point& p) const { return !(*this == p); } }; Double dot(Point p, Point q) { return p.x * q.x + p.y * q.y; } Double dist2(Point p, Point q) { return dot(p - q, p - q); } Double cross(Point p, Point q) { return p.x * q.y - p.y * q.x; } Point norm(Point x, Double l) { return x * sqrt(l * l / dot(x, x)); } istream &operator>>(istream &is, Point &p) { return is >> p.x >> p.y; } Point RotateCCW90(Point p) { return Point(-p.y, p.x); } Point RotateCCW(Point p, Double t) { return Point(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t)); } // project point c onto line through a and b (assuming a != b) Point ProjectPointLine(Point a, Point b, Point c) { return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a); } // project point c onto line segment through a and b (assuming a != b) Point ProjectPointSegment(Point a, Point b, Point c) { Double r = dot(c - a, b - a), d = dot(b - a, b - a); if (r < 0) return a; if (r > d) return b; return a + (b - a) * r / d; } Point reflectAroundLine(Point p, Point a, Point b) { return ProjectPointLine(p, a, b) * 2 - p; } bool LinesParallel(const Point& a, const Point& b, const Point& c, const Point& d) { return isZero(cross(b - a, c - d)); } bool LinesCollinear(const Point& a, const Point& b, const Point& c, const Point& d) { return LinesParallel(a, b, c, d) && isZero(cross(b - c, a - c)); } // Returns 1 if CW, 0 if collinear, -1 if ACW. int getDirection(const Point& a, const Point& b, const Point& c) { auto value = cross(c - a, b - a); if (isZero(value)) return 0; return 2 * (value > 0) - 1; } // Checks if c lies in the range [a,b]. bool checkInRange(Double a, Double b, Double c, Double eps = EPS) { if (areEqual(a, c)) return true; if (areEqual(b, c)) return true; return a <= c && c <= b; } // Assuming that c already lies on the straight line ab, // returns true if c lies on the segment ab. bool onSegment(const Point& a, const Point& b, const Point& c) { return checkInRange(a.x, b.x, c.x) && checkInRange(a.y, b.y, c.y); } // Determine if a to b intersects with c to d. bool SegmentsIntersect(const Point& a, const Point& b, const Point& c, const Point& d) { // Handles collinear cases. auto d1 = getDirection(c, d, a); auto d2 = getDirection(c, d, b); auto d3 = getDirection(a, b, c); auto d4 = getDirection(a, b, d); // tmp if (LinesCollinear(a, b, c, d) && (onSegment(a, b, c) && onSegment(a, b, d) || onSegment(c, d, a) && onSegment(c, d, b))) { return false; } if (d1 == 0 && onSegment(c, d, a)) return true; if (d2 == 0 && onSegment(c, d, b)) return true; if (d3 == 0 && onSegment(a, b, c)) return true; if (d4 == 0 && onSegment(a, b, d)) return true; if (d1 == 0 || d2 == 0 || d3 == 0 || d4 == 0) return false; return (((d1 > 0) == (d2 < 0)) && ((d3 > 0) == (d4 < 0))); } // ST Line ab intersect ST Line cd assuming unique intersection exists // for line segments, check if segments intersect first Point ComputeLineIntersection(Point a, Point b, Point c, Point d) { b = b - a; d = c - d; c = c - a; return a + b * cross(c, d) / cross(b, d); // cross(b,d) != 0 } typedef array<Point, 2> Segment; struct Event { int x, type, y, id; tuple<int, int, int, int> getTuple() const { return make_tuple(x, type, y, id); } bool operator <(const Event& other) const { return getTuple() < other.getTuple(); } Event(int x, int type, int y_end, int id) : x(x), type(type), y(y_end), id(id) { } }; struct SetComparator { static vector<Segment> segments; bool operator()(int a, int b) const { if (segments[a][0].x == segments[b][0].x) { return segments[a][0].y < segments[b][0].y; } if (segments[a][0].y == segments[a][1].y && segments[b][0].y == segments[b][1].y && segments[a][0].y == segments[b][0].y) { return segments[a][0].x < segments[b][0].x; } if (segments[a][0] > segments[b][0]) { int dir = getDirection(segments[b][0], segments[b][1], segments[a][0]); return dir > 0; } int dir = getDirection(segments[a][0], segments[a][1], segments[b][0]); return dir < 0; } }; vector<Segment> SetComparator::segments; bool noIntersection(const vector<Segment>& segments) { int n = segments.size(); vector<Event> events; for (int i = 0; i < n; ++i) { events.emplace_back(segments[i][0].x, segments[i][0] > segments[i][1], segments[i][0].y, i); events.emplace_back(segments[i][1].x, segments[i][0] < segments[i][1], segments[i][1].y, i); } sort(events.begin(), events.end()); SetComparator::segments = segments; set<int, SetComparator> st; for (auto& event : events) { if (event.type == 0) { auto nxt = st.upper_bound(event.id); if (nxt != st.end()) { if (SegmentsIntersect(segments[event.id][0], segments[event.id][1], segments[*nxt][0], segments[*nxt][1])) return false; } if (nxt != st.begin()) { --nxt; if (SegmentsIntersect(segments[event.id][0], segments[event.id][1], segments[*nxt][0], segments[*nxt][1])) return false; } st.insert(event.id); } else { st.erase(event.id); auto nxt = st.upper_bound(event.id); if (nxt != st.end() && nxt != st.begin()) { auto before = nxt; --before; if (SegmentsIntersect(segments[*before][0], segments[*before][1], segments[*nxt][0], segments[*nxt][1])) { return false; } } } } return true; } bool onBorder(const Point& p, int r, int c) { return isZero(p.x) || isZero(p.y) || areEqual(p.x, r) || areEqual(p.y, c); } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #ifdef Local freopen("test.in", "r", stdin); #else #define endl '\n' #endif int r, c, n; cin >> r >> c >> n; vector<Segment> segments; while (n--) { Segment seg; cin >> seg[0] >> seg[1]; sort(seg , seg + 2); if (onBorder(seg[0], r, c) && onBorder(seg[1], r, c)) { segments.emplace_back(seg); } } cout << (noIntersection(segments) ? "YES" : "NO") << endl; }
a.cc: In function 'int main(int, char**)': a.cc:279:20: error: no match for 'operator+' (operand types are 'Segment' {aka 'std::array<Point, 2>'} and 'int') 279 | sort(seg , seg + 2); | ~~~ ^ ~ | | | | | int | Segment {aka std::array<Point, 2>} In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:8: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 279 | sort(seg , seg + 2); | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'const _CharT*' and 'std::array<Point, 2>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'const _CharT*' and 'std::array<Point, 2>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:279:22: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:279:22: note: 'Segment' {aka 'std::array<Point, 2>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 279 | sort(seg , seg + 2); | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:340:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const complex<_Tp>&, const complex<_Tp>&)' 340 | operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:340:5: note: template argument d
s765423366
p03685
C++
#include <bits/stdc++.h> using namespace std; int H, W, N; bool check(int r, int c) { return r == 0 || r == H || c == 0 || c == W; } int calc(int r, int c) { if (r == 0) return c; if (c == W) return W + r; if (r == H) return 2 * W + H - c; if (c == 0) return 2 * (H + W) - r; return -1; } bool solve() { cin >> H >> W >> N; vector<pair<int, int>> v; for (int i = 0; i < N; i++) { int r1, c1; int r2, c2; cin >> r1 >> c1 >> r2 >> c2; if (!check(r1, c1) || !check(r2, c2)) continue; v.emplace_back(calc(r1, c1), i); v.emplace_back(calc(r2, c2), i); } sort(v.begin(), v.end()); if (v.size() == 0) return true; int s, t; if (v[0] == v.size()) { s = 1; t = v.size() - 1; } else { s = 0; t = v.size(); } for (int i = s; i + 1 < t; i+=2) { if (v[i] != v[i+1]) return false; } return true; } int main() { if (solve()) cout << "YES" << endl; else cout << "NO" << endl; }
a.cc: In function 'bool solve()': a.cc:36:12: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'}) 36 | if (v[0] == v.size()) { In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:36:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:36:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 36 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:36:22: note: mismatched types 'const std::pair<_T1, _T2>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 36 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>' 36 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>' 36 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:36:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::fpos<_StateT>' 36 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:235:
s907783791
p03685
C++
#include <bits/stdc++.h> using namespace std; int H, W, N; bool check(int r, int c) { return r == 0 || r == H || c == 0 || c == W; } bool solve() { cin >> H >> W >> N; vector<pair<int, int>> v; for (int i = 0; i < N; i++) { int r1, c1; int r2, c2; cin >> r1 >> c1 >> r2 >> c2; if (!check(r1, c1) || !check(r2, c2)) continue; v.emplace_back(calc(r1, c1), i); v.emplace_back(calc(r2, c2), i); } sort(v.begin(), v.end()); if (v.size() == 0) return true; int s, t; if (v[0] == v.size()) { s = 1; t = v.size() - 1; } else { s = 0; t = v.size(); } for (int i = s; i + 1 < t; i+=2) { if (v[i] != v[i+1]) return false; } return true; } int main() { if (solve()) cout << "YES" << endl; else cout << "NO" << endl; }
a.cc: In function 'bool solve()': a.cc:21:20: error: 'calc' was not declared in this scope 21 | v.emplace_back(calc(r1, c1), i); | ^~~~ a.cc:27:12: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'}) 27 | if (v[0] == v.size()) { In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:27:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:27:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 27 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:27:22: note: mismatched types 'const std::pair<_T1, _T2>' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} 27 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>' 27 | if (v[0] == v.size()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>' 27 | if (v[0] == v.size()) { | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:27:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::fpos<_StateT>' 27 | if (v[0] == v.s
s770462053
p03685
C++
#include "bits/stdc++.h" #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i) #define BUGAVOID(x) x #define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__)) #define sz(c) (int)(c.size()) #define all(c) c.begin(),c.end() #define mp make_pair #define write(x) cout<<(x)<<"\n" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>; template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>; template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); } template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6; constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 }; struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa; int R, C, N; vi X1, X2, Y1, Y2; int main() { cin >> R >> C >> N; X1.resize(N); X2.resize(N); Y1.resize(N); Y2.resize(N); rep(i, N) { cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i]; } // 両端が辺に乗ってるもののみ // 左上0反時計回りに座標振る vp<int, int> sepa; rep(i, N) { if ((X1[i] % C && Y1[i] % R) || (X2[i] % C && Y2[i] % R)) continue; int crd1 = Y1[i] == 0 ? X1[i] : (X1[i] == C ? C + Y1[i] : (Y1[i] == R ? R + C + C - X1[i] : R + 2 * C + R - Y1[i])); int crd2 = Y2[i] == 0 ? X2[i] : (X2[i] == C ? C + Y2[i] : (Y2[i] == R ? R + C + C - X2[i] : R + 2 * C + R - Y2[i])); if (crd1 > crd2) swap(crd1, crd2); sepa.emplace_back(crd1, crd2); } sort(all(sepa)); bool ans = true; if (!sepa.empty()) { int i = 0; while (i < sepa.size()) { int border = sepa[i].second; int j = i + 1; for (; j < sepa.size(); ++j) { if (sepa[j].first > border) break; else if (sepa[j].second > sepa[j - 1].second) { ans = false; } } i = j; } } write(ans ? "YES" : "NO");
a.cc: In function 'int main()': a.cc:71:31: error: expected '}' at end of input 71 | write(ans ? "YES" : "NO"); | ^ a.cc:25:12: note: to match this '{' 25 | int main() { | ^
s414301777
p03685
C++
v#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10; const ll LINF = 1e18; using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define rrep(i, a, b) for (int i = (a); i < (b); i++) #define rrrep(i, a, b) for (int i = (a); i >= (b); i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout << (x) << endl #define Cerr(x) cerr << (x) << endl #define fi first #define se second #define P pair<ll, ll> #define m_p make_pair ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, x2, y2; ld doua; int dy[] = {1, 0, -1, 0}; int dx[] = {0, 1, 0, -1}; //int dy[]={-1,0,1,-1,1,-1,0,1}; //int dx[]={-1,-1,-1,0,0,1,1,1}; string alph("abcdefghijklmnopqrstuvwxyz"), s; bool fl; struct edge { int to, cost; }; pair<P, P> p[ohara]; ll p_cou; ll dat1[ohara],dat2[ohara],dat3[ohara],dat4[ohara]; //-------------------------↓↓↓↓↓↓------------------------ bool border(ll nowy, ll nowx) { if (nowy == 0 || nowx == 0) return true; else if (nowy == h || nowx == w) return true; else return false; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> h >> w >> n; rep(i, n) { cin >> y >> x >> y2 >> x2; dat1[i]=y; dat2[i]=x; dat3[i]=y2; dat4[i]=y2; if (!border(y, x) || !border(y2, x2)) continue; if (y > y2) { swap(x, x2); swap(y, y2); } p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); } sort(p, p + p_cou); ll limx = -1, limy = -1; ll limx2 = -1, limy2 = -1; ll splimx1 = -1, splimx2 = -1, splimx3 = -1, splimx4 = -1, splimy1 = -1, splimy2 = -1, splimy3 = -1, splimy4 = -1; ll dec1, dec2; rep(i, p_cou) { if (p[i].fi.fi == p[i].se.fi) { if (p[i].fi.fi == 0) { if (splimy1 == -1) { splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); } else { if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2)) { Cout("NO"); return 0; } else { splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); } } } else { if (splimy3 == -1) { splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); } else { if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4)) { Cout("NO"); return 0; } else { splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); } } } } ///////////////// else if (p[i].fi.se == p[i].se.se) { if (p[i].fi.se == 0) { if (splimx1 == -1) { splimx1 = min(p[i].fi.fi, p[i].se.fi); splimx2 = max(p[i].fi.fi, p[i].se.fi); } else { if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2)) { Cout("NO"); return 0; } else { splimx1 = min(p[i].fi.fi, p[i].se.fi); splimx2 = max(p[i].fi.fi, p[i].se.fi); } } } else { if (splimx3 == -1) { splimx3 = min(p[i].fi.fi, p[i].se.fi); splimx4 = max(p[i].fi.fi, p[i].se.fi); } else { if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4)) { Cout("NO"); return 0; } else { splimx3 = min(p[i].fi.fi, p[i].se.fi); splimx4 = max(p[i].fi.fi, p[i].se.fi); } } } } else { /////////////////////// if (splimx1 != -1) { if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2 && p[i].fi.se * -1 == 0) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2 && p[i].se.se * -1 == 0)) { Cout("NO"); return 0; } } if (splimx3 != -1) { if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4 && p[i].fi.se * -1 == h) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4 && p[i].se.se * -1 == h)) { //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n"; Cout("NO"); return 0; } } if (splimy1 != -1) { if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2 && p[i].fi.fi == 0) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2 && p[i].se.fi == 0)) { Cout("NO"); return 0; } } if (splimy3 != -1) { if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4 && p[i].fi.fi == w) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4 && p[i].se.fi == w)) { Cout("NO"); return 0; } } /////////////////////// dec1 = 0; dec2 = 0; if (limx == -1 && p[i].fi.fi <= p[i].se.fi) { limx = p[i].se.fi; limy = p[i].fi.se * -1; dec1 = 1; } else if (limx2 == -1 && p[i].fi.fi > p[i].se.fi) { limx2 = p[i].fi.fi; limy2 = p[i].se.se * -1; dec2 = 1; } if (limx != -1 && dec1 == 0) { if ((p[i].se.fi < limx && p[i].se.se * -1 > limy) || ((p[i].fi.fi < limx && p[i].fi.se * -1 > limy))) { Cout("NO"); return 0; } } else if (limx2 != -1 && dec2 == 0) { if ((p[i].se.fi < limx2 && p[i].se.se * -1 < limy) || (p[i].fi.fi < limx2 && p[i].fi.se * -1 < limy)) { Cout("NO"); return 0; } } if (p[i].fi.fi <= p[i].se.fi) { limx = p[i].se.fi; limy = p[i].fi.se * -1; } else if (p[i].fi.fi > p[i].se.fi) { limx2 = p[i].fi.fi; limy2 = p[i].se.se * -1; } } //cerr << limx << " " << limy << " " << limx2 << " " << limy2 << "\n"; } rep(i,n){ if (splimx1 != -1) { if ((splimx1 <= dat2[i] && dat2[i] <= splimx2 && dat1[i] == 0) || (splimx1 <= dat4[i] && dat4[i] <= splimx2 && dat3[i] == 0)) { Cout("NO"); return 0; } } if (splimx3 != -1) { if ((splimx3 <= dat2[i] && dat2[i] <= splimx4 && dat1[i] == h) || (splimx3 <= dat4[i] && dat4[i] <= splimx4 && dat3[i] == h)) { //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n"; Cout("NO"); return 0; } } if (splimy1 != -1) { if ((splimy1 <= dat1[i] && dat1[i] <= splimy2 && dat2[i] == 0) || (splimy1 <= dat3[i] && dat3[i] <= splimy2 && dat4[i] == 0)) { Cout("NO"); return 0; } } if (splimy3 != -1) { if ((splimy3 <= dat1[i] && dat1[i] <= splimy4 && dat2[i] == w) || (splimy3 <= dat3[i] && dat3[i] <= splimy4 && dat4[i] == w)) { Cout("NO"); return 0; } } } Cout("YES"); return 0; }
a.cc:1:2: error: stray '#' in program 1 | v#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'v' does not name a type 1 | v#include <bits/stdc++.h> | ^ a.cc:5:7: error: 'll' does not name a type; did you mean 'ld'? 5 | const ll LINF = 1e18; | ^~ | ld a.cc:20:1: error: 'll' does not name a type; did you mean 'ld'? 20 | ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, x2, y2; | ^~ | ld a.cc:26:1: error: 'string' does not name a type 26 | string alph("abcdefghijklmnopqrstuvwxyz"), s; | ^~~~~~ a.cc:32:1: error: 'pair' does not name a type 32 | pair<P, P> p[ohara]; | ^~~~ a.cc:33:1: error: 'll' does not name a type; did you mean 'ld'? 33 | ll p_cou; | ^~ | ld a.cc:34:1: error: 'll' does not name a type; did you mean 'ld'? 34 | ll dat1[ohara],dat2[ohara],dat3[ohara],dat4[ohara]; | ^~ | ld a.cc:38:13: error: 'll' was not declared in this scope; did you mean 'ld'? 38 | bool border(ll nowy, ll nowx) | ^~ | ld a.cc:38:22: error: 'll' was not declared in this scope; did you mean 'ld'? 38 | bool border(ll nowy, ll nowx) | ^~ | ld a.cc:38:29: error: expression list treated as compound expression in initializer [-fpermissive] 38 | bool border(ll nowy, ll nowx) | ^ a.cc: In function 'int main()': a.cc:50:5: error: 'cin' was not declared in this scope 50 | cin.tie(0); | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | v#include <bits/stdc++.h> a.cc:51:5: error: 'ios' has not been declared 51 | ios::sync_with_stdio(false); | ^~~ a.cc:53:12: error: 'h' was not declared in this scope 53 | cin >> h >> w >> n; | ^ a.cc:53:17: error: 'w' was not declared in this scope 53 | cin >> h >> w >> n; | ^ a.cc:53:22: error: 'n' was not declared in this scope 53 | cin >> h >> w >> n; | ^ a.cc:56:16: error: 'y' was not declared in this scope 56 | cin >> y >> x >> y2 >> x2; | ^ a.cc:56:21: error: 'x' was not declared in this scope 56 | cin >> y >> x >> y2 >> x2; | ^ a.cc:56:26: error: 'y2' was not declared in this scope 56 | cin >> y >> x >> y2 >> x2; | ^~ a.cc:56:32: error: 'x2' was not declared in this scope 56 | cin >> y >> x >> y2 >> x2; | ^~ a.cc:57:9: error: 'dat1' was not declared in this scope 57 | dat1[i]=y; | ^~~~ a.cc:58:9: error: 'dat2' was not declared in this scope 58 | dat2[i]=x; | ^~~~ a.cc:59:9: error: 'dat3' was not declared in this scope 59 | dat3[i]=y2; | ^~~~ a.cc:60:9: error: 'dat4' was not declared in this scope 60 | dat4[i]=y2; | ^~~~ a.cc:61:20: error: 'border' cannot be used as a function 61 | if (!border(y, x) || !border(y2, x2)) | ~~~~~~^~~~~~ a.cc:61:37: error: 'border' cannot be used as a function 61 | if (!border(y, x) || !border(y2, x2)) | ~~~~~~^~~~~~~~ a.cc:65:13: error: 'swap' was not declared in this scope 65 | swap(x, x2); | ^~~~ a.cc:68:9: error: 'p' was not declared in this scope 68 | p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); | ^ a.cc:68:11: error: 'p_cou' was not declared in this scope 68 | p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); | ^~~~~ a.cc:18:13: error: 'make_pair' was not declared in this scope 18 | #define m_p make_pair | ^~~~~~~~~ a.cc:68:26: note: in expansion of macro 'm_p' 68 | p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); | ^~~ a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' +++ |+#include <utility> 1 | v#include <bits/stdc++.h> a.cc:18:13: error: 'make_pair' was not declared in this scope 18 | #define m_p make_pair | ^~~~~~~~~ a.cc:68:22: note: in expansion of macro 'm_p' 68 | p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); | ^~~ a.cc:18:13: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' 18 | #define m_p make_pair | ^~~~~~~~~ a.cc:68:22: note: in expansion of macro 'm_p' 68 | p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); | ^~~ a.cc:70:10: error: 'p' was not declared in this scope 70 | sort(p, p + p_cou); | ^ a.cc:70:17: error: 'p_cou' was not declared in this scope 70 | sort(p, p + p_cou); | ^~~~~ a.cc:70:5: error: 'sort' was not declared in this scope; did you mean 'short'? 70 | sort(p, p + p_cou); | ^~~~ | short a.cc:71:5: error: 'll' was not declared in this scope; did you mean 'ld'? 71 | ll limx = -1, limy = -1; | ^~ | ld a.cc:72:7: error: expected ';' before 'limx2' 72 | ll limx2 = -1, limy2 = -1; | ^~~~~~ | ; a.cc:73:7: error: expected ';' before 'splimx1' 73 | ll splimx1 = -1, splimx2 = -1, splimx3 = -1, splimx4 = -1, splimy1 = -1, splimy2 = -1, splimy3 = -1, splimy4 = -1; | ^~~~~~~~ | ; a.cc:74:7: error: expected ';' before 'dec1' 74 | ll dec1, dec2; | ^~~~~ | ; a.cc:81:21: error: 'splimy1' was not declared in this scope 81 | if (splimy1 == -1) | ^~~~~~~ a.cc:83:31: error: 'min' was not declared in this scope; did you mean 'main'? 83 | splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ | main a.cc:84:21: error: 'splimy2' was not declared in this scope 84 | splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); | ^~~~~~~ a.cc:84:31: error: 'max' was not declared in this scope 84 | splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ a.cc:88:75: error: 'splimy2' was not declared in this scope 88 | if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2)) | ^~~~~~~ a.cc:13:17: error: 'cout' was not declared in this scope 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:90:25: note: in expansion of macro 'Cout' 90 | Cout("NO"); | ^~~~ a.cc:13:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:90:25: note: in expansion of macro 'Cout' 90 | Cout("NO"); | ^~~~ a.cc:13:32: error: 'endl' was not declared in this scope 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:90:25: note: in expansion of macro 'Cout' 90 | Cout("NO"); | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | v#include <bits/stdc++.h> a.cc:95:35: error: 'min' was not declared in this scope; did you mean 'main'? 95 | splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ | main a.cc:96:35: error: 'max' was not declared in this scope 96 | splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ a.cc:102:21: error: 'splimy3' was not declared in this scope 102 | if (splimy3 == -1) | ^~~~~~~ a.cc:104:31: error: 'min' was not declared in this scope; did you mean 'main'? 104 | splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ | main a.cc:105:21: error: 'splimy4' was not declared in this scope 105 | splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); | ^~~~~~~ a.cc:105:31: error: 'max' was not declared in this scope 105 | splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); | ^~~ a.cc:109:75: error: 'splimy4' was not declared in this scope 109 | if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4)) | ^~~~~~~ a.cc:13:17: error: 'cout' was not declared in this scope 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:111:25: note: in expansion of macro 'Cout' 111 | Cout("NO"); | ^~~~ a.cc:13:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:111:25: note: in expansion of macro 'Cout' 111 | Cout("NO"); | ^~~~ a.cc:13:32: error: 'endl' was not declared in this scope 13 | #define Cout(x) cout << (x) << endl | ^~~~ a.cc:111:25: note: in expansion of macro 'Cout' 111 | Cout("NO"); | ^~~~ a.cc:13:32: note: 'std::endl' is defined in he
s448236281
p03685
C++
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10; const ll LINF = 1e18; using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define rrep(i, a, b) for (int i = (a); i < (b); i++) #define rrrep(i, a, b) for (int i = (a); i >= (b); i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout << (x) << endl #define Cerr(x) cerr << (x) << endl #define fi first #define se second #define P pair<ll, ll> #define m_p make_pair ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, x2, y2; ld doua; int dy[] = {1, 0, -1, 0}; int dx[] = {0, 1, 0, -1}; //int dy[]={-1,0,1,-1,1,-1,0,1}; //int dx[]={-1,-1,-1,0,0,1,1,1}; string alph("abcdefghijklmnopqrstuvwxyz"), s; bool fl; struct edge { int to, cost; }; pair<P, P> p[ohara]; ll p_cou; ll dat1[ohara],dat2[ohara],dat3[ohara],dat4[ohara]; //-------------------------↓↓↓↓↓↓------------------------ bool border(ll nowy, ll nowx) { if (nowy == 0 || nowx == 0) return true; else if (nowy == h || nowx == w) return true; else return false; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> h >> w >> n; rep(i, n) { cin >> y >> x >> y2 >> x2; dat1[i]=y; dat2[i]=x; dat3[i]=y2; dat4[i]=y2; if (!border(y, x) || !border(y2, x2)) continue; if (y > y2) { swap(x, x2); swap(y, y2); } p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2)); } sort(p, p + p_cou); ll limx = -1, limy = -1; ll limx2 = -1, limy2 = -1; ll splimx1 = -1, splimx2 = -1, splimx3 = -1, splimx4 = -1, splimy1 = -1, splimy2 = -1, splimy3 = -1, splimy4 = -1; ll dec1, dec2; rep(i, p_cou) { if (p[i].fi.fi == p[i].se.fi) { if (p[i].fi.fi == 0) { if (splimy1 == -1) { splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); } else { if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2)) { Cout("NO"); return 0; } else { splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1); } } } else { if (splimy3 == -1) { splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); } else { if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4)) { Cout("NO"); return 0; } else { splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1); splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1); } } } } ///////////////// else if (p[i].fi.se == p[i].se.se) { if (p[i].fi.se == 0) { if (splimx1 == -1) { splimx1 = min(p[i].fi.fi, p[i].se.fi); splimx2 = max(p[i].fi.fi, p[i].se.fi); } else { if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2)) { Cout("NO"); return 0; } else { splimx1 = min(p[i].fi.fi, p[i].se.fi); splimx2 = max(p[i].fi.fi, p[i].se.fi); } } } else { if (splimx3 == -1) { splimx3 = min(p[i].fi.fi, p[i].se.fi); splimx4 = max(p[i].fi.fi, p[i].se.fi); } else { if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4)) { Cout("NO"); return 0; } else { splimx3 = min(p[i].fi.fi, p[i].se.fi); splimx4 = max(p[i].fi.fi, p[i].se.fi); } } } } else { /////////////////////// if (splimx1 != -1) { if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2 && p[i].fi.se * -1 == 0) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2 && p[i].se.se * -1 == 0)) { Cout("NO"); return 0; } } if (splimx3 != -1) { if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4 && p[i].fi.se * -1 == h) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4 && p[i].se.se * -1 == h)) { //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n"; Cout("NO"); return 0; } } if (splimy1 != -1) { if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2 && p[i].fi.fi == 0) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2 && p[i].se.fi == 0)) { Cout("NO"); return 0; } } if (splimy3 != -1) { if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4 && p[i].fi.fi == w) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4 && p[i].se.fi == w)) { Cout("NO"); return 0; } } /////////////////////// dec1 = 0; dec2 = 0; if (limx == -1 && p[i].fi.fi <= p[i].se.fi) { limx = p[i].se.fi; limy = p[i].fi.se * -1; dec1 = 1; } else if (limx2 == -1 && p[i].fi.fi > p[i].se.fi) { limx2 = p[i].fi.fi; limy2 = p[i].se.se * -1; dec2 = 1; } if (limx != -1 && dec1 == 0) { if ((p[i].se.fi < limx && p[i].se.se * -1 > limy) || ((p[i].fi.fi < limx && p[i].fi.se * -1 > limy))) { Cout("NO"); return 0; } } else if (limx2 != -1 && dec2 == 0) { if ((p[i].se.fi < limx2 && p[i].se.se * -1 < limy) || (p[i].fi.fi < limx2 && p[i].fi.se * -1 < limy)) { Cout("NO"); return 0; } } if (p[i].fi.fi <= p[i].se.fi) { limx = p[i].se.fi; limy = p[i].fi.se * -1; } else if (p[i].fi.fi > p[i].se.fi) { limx2 = p[i].fi.fi; limy2 = p[i].se.se * -1; } } //cerr << limx << " " << limy << " " << limx2 << " " << limy2 << "\n"; } rep(i,n){ if (splimx1 != -1) { if ((splimx1 <= dat2[i] && dat2[i] <= splimx2 && dat1[i] == 0) || (splimx1 <= dat4[i] && dat4[i] <= splimx2 && dat[3] == 0)) { Cout("NO"); return 0; } } if (splimx3 != -1) { if ((splimx3 <= dat2[i] && dat2[i] <= splimx4 && dat1[i] == h) || (splimx3 <= dat4[i] && dat4[i] <= splimx4 && dat3[i] == h)) { //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n"; Cout("NO"); return 0; } } if (splimy1 != -1) { if ((splimy1 <= dat1[i] && dat1[i] <= splimy2 && dat2[i] == 0) || (splimy1 <= dat3[i] && dat3[i] <= splimy2 && dat4[i] == 0)) { Cout("NO"); return 0; } } if (splimy3 != -1) { if ((splimy3 <= dat1[i] && dat1[i] <= splimy4 && dat2[i] == w) || (splimy3 <= dat3[i] && dat3[i] <= splimy4 && dat4[i] == w)) { Cout("NO"); return 0; } } } Cout("YES"); return 0; }
a.cc: In function 'int main()': a.cc:250:128: error: 'dat' was not declared in this scope; did you mean 'dat4'? 250 | if ((splimx1 <= dat2[i] && dat2[i] <= splimx2 && dat1[i] == 0) || (splimx1 <= dat4[i] && dat4[i] <= splimx2 && dat[3] == 0)) | ^~~ | dat4
s749582068
p03685
C++
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class S, class T> using P = pair<S, T>; template <class S, class T, class U> using TP = tuple<S, T, U>; using ll = long long; using ull = unsigned long long; using dbl = double; using str = string; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using tl = TP<ll, ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; using vtl = V<tl>; using vvtl = V<vtl>; using vs = V<str>; using vvs = V<vs>; using vd = V<dbl>; using vvd = V<vd>; using qll = queue<ll>; using qpl = queue<pl>; using stll = stack<ll>; using stpl = stack<pl>; using mapll = map<ll, ll>; using setll = set<ll>; using pqll = priority_queue<ll>; #define int ll #define fi first #define se second #define mp make_pair #define mt make_tuple #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define inv inverse() #define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(b);i>=(ll)(a);i--) #define REP(i,a) FOR((i),0,(ll)(a)-1) #define REP0(i,a) FOR((i),0,(ll)(a)) #define REP1(i,a) FOR((i),1,(ll)(a)) #define rREP(i,a) rFOR((i),0,(ll)(a)-1) #define rREP0(i,a) rFOR((i),0,(ll)(a)) #define rREP1(i,a) rFOR((i),1,(ll)(a)) #define ROR(v,i) for(auto &(i):(v)) #define IOTA(a,n) iota((a).bgn,(a).en,(n)) #define SORT(a) sort((a).bgn,(a).en) #define rSORT(a) sort((a).rbegin(),(a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn,(a).en),(a).en) #define PREVP(a) prev_permutation((a).bgn,(a).en) #define NEXTP(a) next_permutation((a).bgn,(a).en) #define BINS(a,b) binary_search((a).bgn,(a).en,(b)) #define LOWB(a,b) (lower_bound((a).bgn,(a).en,(b))-(a).bgn) #define UPB(a,b) (upper_bound((a).bgn,(a).en,(b))-(a).bgn) #define CNT(a,b) count((a).bgn,(a).en,b) #define SUM(a) accumulate((a).bgn,(a).en,0) #define REV(a) reverse((a).bgn,(a).en) #define REGS(a,b) regex_search((a),regex(b)) #define REGM(a,b) regex_match((a),regex(b)) #define yn(a) cout <<((a)?"yes":"no")<<"\n"; #define Yn(a) cout <<((a)?"Yes":"No")<<"\n"; #define YN(a) cout <<((a)?"YES":"NO")<<"\n"; #define imp(a) cout <<((a)?"possible":"impossible")<<"\n"; #define Imp(a) cout <<((a)?"Possible":"Impossible")<<"\n"; #define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<"\n"; #define fs(a) cout <<((a)?"second":"first")<<"\n"; #define Fs(a) cout <<((a)?"Second":"First")<<"\n"; #define FS(a) cout <<((a)?"SECOND":"FIRST")<<"\n"; #define sak cout <<"\n"; #define sas cout <<" "; #define sat cout <<"\t"; #define dbg(a) cerr <<(#a)<<": "<<(a)<<"\n"; #define dbgs(...) dal(#__VA_ARGS__);dal(__VA_ARGS__); #define c2l(a) ((ll)(a-48)) #define a2l(a) ((ll)(a-97)) #define A2l(a) ((ll)(a-65)) #define l2c(a) ((char)(a+48)) #define l2a(a) ((char)(a+97)) #define l2A(a) ((char)(a+65)) #define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1)) #define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1)) #define Dig2(a,b) (((a)>>(b))&1) #define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10) #define Pow2(a) ((ll)(1)<<(a)) #define Pow10(a) ((ll)(pow(10.0,double(a)))) #define LSB(a) ((a)&(-(a))) #define vin(v) ROR((v),(i)){cin >>(i);}; #define vllin(v,N) vll (v)((N));vin(v); #define vllin2(a,b,N) vll (a)(N),(b)(N);REP(i,N){cin>>(a)[i]>>(b)[i];}; #define vsin(v,N) vs (v)((N));vin(v); #define rdn(a,b) ((a)/(b)) #define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1)) #define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1)) #define min(...) Min(__VA_ARGS__) #define max(...) Max(__VA_ARGS__) #define emin(a, ...) ((a)=Min((a),__VA_ARGS__)) #define emax(a, ...) ((a)=Max((a),__VA_ARGS__)) #define egcd(a, ...) ((a)=gcd((a),__VA_ARGS__)) #define elcm(a, ...) ((a)=lcm((a),__VA_ARGS__)) #define powll(a,b) (ll)(pow((double)(a),(double)(b))) #define Triangle(x1,y1,x2,y2,x3,y3) (((x1)-(x2))*((y1)-(y3))-((x1)-(x3))*((y1)-(y2))) #define svll SumV<ll> #define svvll SumV2<ll> #define li(...) ll __VA_ARGS__;Input(__VA_ARGS__); #define si(...) str __VA_ARGS__;Input(__VA_ARGS__); #define vli(size, ...) vll __VA_ARGS__;vInput(size,__VA_ARGS__); #define vsi(size, ...) vs __VA_ARGS__;vInput(size,__VA_ARGS__); const ll MOD = 1e9 + 7; //const ll MOD = 998244353; //const ll MOD = 924844033; //const ll MOD = 9007199254740881; const ll INF = 1LL << 60;//1.15e18 const double PI = acos(-1.0); const vll DX = { 0,-1,0,1,0,-1,1,1,-1 }; const vll DY = { 0,0,-1,0,1,-1,-1,1,1 }; const str alp = "abcdefghijklmnopqrstuvwxyz"; const str ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void Input() {} template <class Var, class... Args> void Input(Var& var, Args&... args) { cin >> var; Input(args...); } void vInit(ll size) {} template <class T, class... Args> void vInit(ll size, V<T>& v, Args&... args) { v.res(size); vInit(size, args...); } void vInputNum(ll num) {} template <class T, class... Args> void vInputNum(ll num, V<T>& v, Args&... args) { cin >> v[num]; vInputNum(num, args...); } void vInput(ll size) {} template <class... Args> void vInput(ll size, Args&... args) { vInit(size, args...); REP(i, size) vInputNum(i, args...); } template <class S, class T> ostream &operator<<(ostream &out, const P<S, T> &p) { return out << "[" << p.fi << ", " << p.se << "]"; } template <class T> ostream &operator<<(ostream &out, V<T> &v) { if (v.emp) return out << "{}"; else { auto itr = v.bgn; out << "{" << *itr; itr++; while (itr != v.en) { out << ", " << *itr; itr++; } out << "}"; return out; } } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> &m) { if (m.emp) return out << "<[]>"; else { auto itr = m.bgn; out << "< [" << (itr->fi) << ": " << (itr->se); itr++; while (itr != m.en) { out << "], [" << (itr->fi) << ": " << (itr->se); itr++; } out << "] >"; return out; } } template <class T> ostream &operator<<(ostream &out, const set<T> &s) { if (s.emp) return out << "<>"; else { auto itr = s.bgn; out << "<" << *itr; itr++; while (itr != s.en) { out << ", " << *itr; itr++; } out << ">"; return out; } } void say() {} template <class T> void say(T t) { cout << t; } template <class Head, class... Body> void say(Head head, Body... body) { cout << head << " "; say(body...); } void sal() { cout << "\n"; } template <class... Args> void sal(Args... args) { say(args...); cout << "\n"; } void day() {} template <class T> void day(T t) { cerr << t; } template <class Head, class... Body> void day(Head head, Body... body) { cerr << head << " "; day(body...); } void dal() { cerr << "\n"; } template <class... Args> void dal(Args... args) { day(args...); cerr << "\n"; } void salv() {} template <class T> void salv(V<T> v) { if (v.emp) sal(); else { auto itr = v.bgn; say(*itr); itr++; while (itr != v.en) { sas; say(*itr); itr++; } sak; } } template <class T, class... Args> void salv(V<T> v, Args... args) { salv(v); salv(args...); } void salv2() {} template <class T> void salv2(V<V<T>> v) { if (v.emp) sal(); else { ROR(v, i) salv(i); } } template <class T, class... Args> void salv2(V<V<T>> v, Args... args) { salv2(v); salv2(args...); } template <class Monoid> struct Action { public: Monoid I; function<Monoid(Monoid, Monoid)> A; Action(Monoid I, function<Monoid(Monoid, Monoid)> A) : I(I), A(A) {} Monoid operator()() { return I; } Monoid operator()(Monoid x) { return x; } Monoid operator()(Monoid l, Monoid r) { return A(l, r); } template <class... Args> Monoid operator()(Monoid x, Args... args) { Monoid tmp = operator()(args...); return A(x, tmp); } }; template <class T> Action<T> ADD = Action<T>(0, [](T l, T r) { return l + r; }); template <> Action<str> ADD<str> = Action<str>("", [](str l, str r) { return l + r; }); template <class T1, class T2> Action<P<T1, T2>> ADD<P<T1, T2>> = Action<P<T1, T2>>(mp(ADD<T1>.I, ADD<T2>.I), [](P<T1, T2> l, P<T1, T2> r) { return mp(l.fi + r.fi, l.se + r.se); }); template <class T> Action<T> MUL = Action<T>(1, [](T l, T r) { return l * r; }); template <class T> Action<T> OR = Action<T>(0, [](T l, T r) { return l | r; }); template <class T> Action<T> XOR = Action<T>(0, [](T l, T r) { return l ^ r; }); template <class T> Action<T> AND = Action<T>(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; }); template <> Action<bool> AND<bool> = Action<bool>(true, [](bool l, bool r) { return l & r; }); template <> Action<ull> AND<ull> = Action<ull>(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; }); template <class T> Action<T> MIN = Action<T>(INF, [](T l, T r) { return (l < r) ? l : r; }); template <class T> Action<T> MAX = Action<T>(-INF, [](T l, T r) { return (l > r) ? l : r; }); template <class T> Action<T> GCD = Action<T>(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD<T>(r, l%r) : l); }); template <class T> Action<T> LCM = Action<T>(1, [](T l, T r) { return (l * r) / GCD<T>(l, r); }); template <class Head> Head Min(Head head) { return head; } template <class Head, class... Body> Head Min(Head head, Body... body) { auto tmp = Min(body...); return (head < tmp) ? head : tmp; } template <class Head> Head Max(Head head) { return head; } template <class Head, class... Body> auto Max(Head head, Body... body) { auto tmp = Max(body...); return (head > tmp) ? head : tmp; } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a%b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } ll gcd(ll head) { return head; } template <class... Body> ll gcd(ll head, Body... body) { return gcd(head, gcd(body...)); } ll lcm(ll head) { return head; } template <class... Body> ll lcm(ll head, Body... body) { return lcm(head, lcm(body...)); } ll Bset(ll a, ll b, ll c) { if (c) a |= b; else a &= ~b; return a; } struct UFT { public: ll tsize; ll mode; vll par; vll rank; UFT() {} UFT(const UFT &uft) {} UFT(ll tsizeget, ll modeget = 0){ tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); } ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } ll size(ll x) { return -par[root(x)]; } }; struct pUFT { public: ll tsize; ll now; vll par; vll rank; vll mtime; vvll sizepi; vvll sizepv; pUFT(){} pUFT(const pUFT &puft) {} pUFT(ll tsizeget) { tsize = tsizeget; now = 0; par.asn(tsize, -1); rank.asn(tsize, 0); mtime.asn(tsize, INF); sizepi.asn(tsize, { 0 }); sizepv.asn(tsize, { 1 }); } ll root(ll x, ll t) { return (mtime[x] > t) ? x : root(par[x], t); } bool same(ll x, ll y, ll t) { return root(x, t) == root(y, t); } ll merge(ll x, ll y) { now++; x = root(x, now); y = root(y, now); if (x != y) { if (rank[x] < rank[y]) { par[y] += par[x]; sizepi[y].pb(now); sizepv[y].pb(-par[y]); par[x] = y; mtime[x] = now; } else { par[x] += par[y]; sizepi[x].pb(now); sizepv[x].pb(-par[x]); par[y] = x; mtime[y] = now; if (rank[x] == rank[y]) rank[x]++; } } return now; } ll size(ll x, ll t) { x = root(x, t); return sizepv[x][UPB(sizepi[x], t) - 1]; } }; struct wUFT { public: ll tsize; ll mode; vll par; vll rank; vll dweight; wUFT() {} wUFT(const wUFT &wuft) {} wUFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); dweight.asn(tsize, 0); } ll root(ll x) { if (par[x] < 0) return x; else { ll r = root(par[x]); dweight[x] += dweight[par[x]]; return par[x] = r; } } ll weight(ll x) { root(x); return dweight[x]; } ll diff(ll x, ll y) { return weight(y) - weight(x); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y, ll w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; dweight[x] = -w; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; dweight[y] = w; } } } ll size(ll x) { return -par[root(x)]; } }; template <typename valtype> class SegT { public: ll size; vector<valtype> v; valtype initv; function<valtype(valtype x, valtype y)> calc; SegT() {} SegT(const SegT &segt) {} SegT(ll sizeget, ll modeget = 0) { sizeset(sizeget); modeset(modeget); init(); } SegT(vector<valtype> cpyvec, ll modeget = 0) { sizeset(cpyvec.sz); modeset(modeget); init(); copy(cpyvec); } SegT(ll sizeget, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(sizeget); initv = initvget; calc = calcget; init(); } SegT(vector<valtype> cpyvec, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(cpyvec.sz); initv = initvget; calc = calcget; init(); copy(cpyvec); } void sizeset(ll rsize) { size = DigN2(rsize); if (rsize == Pow2(size - 1)) size--; return; } void modeset(ll mode) { switch (mode) { case 0: initv = 0; calc = [](valtype x, valtype y) {return x + y; }; break; case 1: initv = INF; calc = [](valtype x, valtype y) {return min(x, y); }; break; case 2: initv = -INF; calc = [](valtype x, valtype y) {return max(x, y); }; break; } return; } void init() { v.asn(Pow2(size + 1) - 1, initv); } void copy(vector<valtype> cpyvec) { REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]); } ll i2v(ll i) const{ if (i < 0 || i >= Pow2(size)) return -1; return Pow2(size) + i - 1; } ll top(ll i) const{ if (i == 0) return -1; return (i - 1) / 2; } pl bot(ll i) const{ if (i + 1 >= Pow2(size)) return mp(-1, -1); return mp(2 * i + 1, 2 * i + 2); } void set(ll i, valtype x) { i = i2v(i); v[i] = x; while (i > 0) { i = top(i); v[i] = calc(v[bot(i).fi], v[bot(i).se]); } return; } void add(ll i, valtype x) { set(i, v[i2v(i)] + x); return; } valtype operator[](const ll &i) const { return v[i2v(i)]; } // valtype que(ll a = 0, ll b = Pow2(size) - 1) { valtype que(ll a, ll b) { if (a == b) return v[i2v(a)]; if (a > b) return initv;//swap(a, b); valtype ans = initv; ll ai = i2v(a); ll bi = i2v(b); FOR(i, 1, size + 1) { if (a > b) break; if (a%Pow2(i)) { ans = calc(ans, v[ai]); a += Pow2(i - 1); ai = top(ai) + 1; } else { ai = top(ai); } if (a > b) break; if ((b + 1) % Pow2(i)) { ans = calc(ans, v[bi]); b -= Pow2(i - 1); bi = top(bi) - 1; } else { bi = top(bi); } if (a > b) break; } return ans; } valtype que(ll b) { return que(0, b); } valtype que() { return que(0, Pow2(size) - 1); } }; template <typename lentype> class Graph { public: ll size; ll mode; ll mapmode; lentype zlen; lentype ilen; vector<map<ll, ll>> v2n; vvll n2v; vector<vector<lentype>> Edge; vector<pair<lentype, ll>> Primresult; Graph() {} Graph(const Graph &graph) {} Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) { size = sizeget; mapmode = mapmodeget; mode = modeget; zlen = zlenget; ilen = ilenget; init(); } void init() { Edge.res(size); v2n.res(size); n2v.res(size); Primresult.asn(size, mp(ilen, -1)); } lentype lenplus(lentype l, lentype r) { return l + r; } lentype lenequal(lentype l, lentype r) { return l == r; } lentype lenlcr(lentype l, lentype r) { return l < r; } ll addV(ll vs) { size += vs; init(); return size; } void caddE(ll x, ll y, lentype c) { if (mapmode) v2n[x][y] = Edge[x].sz; Edge[x].pb(c); n2v[x].pb(y); } void csetE(ll x, ll y, lentype c) { if (mapmode) Edge[x][v2n[x][y]] = c; } void cersE(ll x, ll y) { if (mapmode) { ll n = v2n[x][y]; Edge[x][n] = ilen; n2v[x][n] = -1; v2n[x].ers(y); } } void addE(ll x, ll y, lentype c) { caddE(x, y, c); if (!mode) caddE(y, x, c); } void setE(ll x, ll y, lentype c) { csetE(x, y, c); if (!mode) csetE(y, x, c); } void ersE(ll x, ll y, lentype c) { cersE(x, y, c); if (!mode) cersE(y, x, c); } lentype getE(ll x, ll y) { if (mapmode) { if (v2n[x].count(y)) { return Edge[x][v2n[x][y]]; } } return ilen; } ll getVsz(ll x) { return Edge[x].sz; } pair<lentype, ll> getV(ll x, ll n) { if (n >= getVsz(x)) return mp(ilen, -1); return mp(Edge[x][n], n2v[x][n]); } vector<pair<lentype, vll>> Dijk(ll x) { vector<pair<lentype, vll>> result(size); REP(i, size) { result[i].fi = ilen; result[i].se = { -1 }; } vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); result[x].fi = zlen; result[x].se = { -1 }; while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = { now.se }; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = { now.se }; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].se.pb(now.se); } } } } return result; } lentype Prim(ll x = 0) { lentype ans = zlen; vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); Primresult[x] = mp(zlen, -1); while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; ans = lenplus(ans, Primresult[now.se].fi); REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } } } } return ans; } }; /*template <class Type> class DP { public: vector<Type> v; Type initv; vll size, block; DP() {} DP(const DP &dp) {} template<class... Args> DP(Args... args) { block.asn(1, 1); Initialize(args...); } void Initialize(Type initv_) { initv = initv_; v.asn(block.bk, initv); } template<class... Args> void Initialize(ll val, Args... args) { size.pb(val); block.pb(block.bk*val); Initialize(args...); } };*/ pl Bezout(ll a, ll b) { if (b != 0) { pl xy; xy = Bezout(b, a%b); return mp(xy.se, xy.fi - ((a / b)*xy.se)); } else { return mp(1, 0); } } pl Bez(ll a, ll b, ll c) { pl xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c%gc != 0) return mp(-1, -1); x = xy.fi*(c / gc); y = xy.se*(c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } ll DigS10(ll n) { ll ans = 0; while(1) { ans += n % 10; n /= 10; if (!n) break; } return ans; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n) + 1) { if (n%i == 0) return 0; } return 1; } ll Tot(ll n) { if (n <= 0) return 0; ll ans = n, x = 2; while (x*x <= n) { if (n%x == 0) { ans -= ans / x; while (n%x == 0) n /= x; } x++; } if (n > 1) ans -= ans / n; return ans; } template <class T> struct Sum { public: V<T> v, s; ll size; Action<T> Add; Sum(V<T> v, Action<T> Add = ADD<T>) : v(v), size(v.sz), Add(Add) { Init(); Calc(); } void Init() { s.asn(size + 1, Add.I); } void Calc() { REP(i, size) s[i + 1] = Add(s[i], v[i]); } T operator()(ll x) { return operator()(0, x); } T operator()(ll l, ll r) { if (l < 0) l = 0; if (r >= size) r = size - 1; if (l > r) return Add.I; return s[r + 1] - s[l];//for ADD } }; using sumll = Sum<ll>; template <class T> struct Sum2 { public: V<V<T>> v, s; ll RowSize, ColumnSize; Action<T> Add; Sum2(V<V<T>> v, Action<T> Add = ADD<T>) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); } void Init() { s.asn(RowSize + 1, V<T>(ColumnSize, Add.I)); } void Calc() { REP1(r, RowSize) { REP1(c, ColumnSize) { s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1); } } } T operator()(ll r, ll c) { return operator()(0, 0, r, c); } T operator()(ll r1, ll c1, ll r2, ll c2) { if (r1 < 0) r1 = 0; if (c1 < 0) c1 = 0; if (r2 >= RowSize) r2 = RowSize - 1; if (c2 >= ColumnSize) c2 = ColumnSize - 1; if (r1 > r2) return Add.I; if (c1 > c2) return Add.I; return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1]; } }; using sum2ll = Sum2<ll>; template <class T> struct Point2 { public: V<V<T>> v; ll h, w; Point2() : h(0), w(0) {} Point2(ll h, ll w) : h(h), w(w) { asn(h, w); } Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); } void assign(ll h, ll w) { v.asn(h, V<T>(w)); } void assign(ll h, ll w, ll val) { v.asn(h, V<T>(w, val)); } T& operator()(ll h, ll w) { return v[h][w]; } T& operator()(pl p) { return v[p.fi][p.se]; } }; template <class T> using P2 = Point2<T>; template <ll Mod> struct Modll { public: ll v; Modll() : v(0) {} Modll(ll _v) { set(_v % Mod + Mod); } Modll& set(ll _v) { v = (_v < Mod) ? _v : (_v - Mod); return *this; } Modll pow(ll n) const { Modll x = *this, ans = 1; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } Modll inverse() const { return (*this).pow(Mod - 2); } Modll operator+(const Modll& m) const { return Modll().set(v + m.v); } Modll operator-(const Modll& m) const { return Modll().set(Mod + v - m.v); } Modll operator*(const Modll& m) const { return Modll().set((ull(v) * m.v) % Mod); } Modll operator/(const Modll& m) const { return *this * m.inv; } Modll& operator+=(const Modll& m) { return *this = *this + m; } Modll& operator-=(const Modll& m) { return *this = *this - m; } Modll& operator*=(const Modll& m) { return *this = *this * m; } Modll& operator/=(const Modll& m) { return *this = *this / m; } Modll operator-() const { return Modll(0) - *this; } explicit operator bool() const { return v != 0; } friend ostream& operator<<(ostream& out, const Modll& m) { return out << m.v; } }; using mll = Modll<MOD>; using vmll = V<mll>; using vvmll = V<vmll>; using vvvmll = V<vvmll>; template <class T> T vmin(V<T> v) { T tmp = MIN<T>.I; ROR(v, i) emin(tmp, i); return tmp; } template <class T, class... Args> T vmin(V<T> v, Args... args) { T tmp = vmin(args...); return min(vmin(v), tmp); } template <class T> T vmax(V<T> v) { T tmp = MAX<T>.I; ROR(v, i) emax(tmp, i); return tmp; } template <class T, class... Args> T vmax(V<T> v, Args... args) { T tmp = vmax(args...); return max(vmax(v), tmp); } template <class T> T vgcd(V<T> v) { T tmp = GCD<T>.I; ROR(v, i) egcd(tmp, i); return tmp; } template <class T, class... Args> T vgcd(V<T> v, Args... args) { T tmp = vgcd(args...); return gcd(vgcd(v), tmp); } template <class T> T vlcm(V<T> v) { T tmp = LCM<T>.I; ROR(v, i) elcm(tmp, i); return tmp; } template <class T, class... Args> T vlcm(V<T> v, Args... args) { T tmp = vlcm(args...); return lcm(vlcm(v), tmp); } vmll MFactMemo(2, 1); vmll MIFactMemo(2, 1); mll mFact(ll n) { if (MFactMemo.sz <= n) { ll oldsize = MFactMemo.sz; MFactMemo.res(n + 1, 1); FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i; } return MFactMemo[n]; } mll miFact(ll n) { if (MIFactMemo.sz <= n) { ll oldsize = MIFactMemo.sz; MIFactMemo.res(n + 1, 1); MIFactMemo.bk = mFact(n).inv; rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i; } return MIFactMemo[n]; } mll mComb(ll n, ll k) { if (n < 0 || k < 0 || n < k) return 0; return mFact(n) * miFact(k) * miFact(n - k); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void PCmprs(vll& v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) {return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) {return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { PCmprs(v); SegT<ll> b(v.sz, 0); ll ans = 0; REP(i, v.sz) { ans += (i - b.que(0, v[i])); b.add(v[i], 1); } return ans; } ll Bsrch(function<bool(ll x)> f, ll mi, ll ma) { ll ng = mi - 1, ok = ma, mid; while (ok - ng > 1) { mid = (ng + ok) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template<class T> V<V<T>> MultiMatrix(V<V<T>> A, V<V<T>> B, Action<T> Mul = MUL<T>, Action<T> Add = ADD<T>) { V<V<T>> ans; ll ii = A.sz; if (!ii) return ans; ll jj = A[0].sz; if (!jj) return ans; ll jj2 = B.sz; if (!jj2) return ans; if (jj != jj2) return ans; ll kk = B[0].sz; if (!kk) return ans; ans.asn(ii, V<T>(kk, 0)); REP(i, ii) { REP(k, kk) { REP(j, jj) { ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k])); } } } return ans; } vvll CombMemo(1000, vll(1000, -1)); ll Comb(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (CombMemo[n][k] == -1) { if (n < k) CombMemo[n][k] = 0; else { if (n == 0) CombMemo[n][k] = 1; else if (k == 0) CombMemo[n][k] = 1; else if (n == k) CombMemo[n][k] = 1; else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k); } } return CombMemo[n][k]; } template<class T> map<T, ll> Dict(V<T> v) { map<T, ll> m; if (!v.sz) return m; SORT(v); UNIQUE(v); REP(i, v.sz) { m[v[i]] = i; } return m; } template<class T> vll Cmprs(V<T> v) { auto m = Dict(v); vll ans(v.sz); REP(i,v.sz) { ans[i] = m[v[i]]; } return ans; } template <class T> auto vecn(T val) { return val; } template <class... Args> auto vecn(ll val, Args... args) { auto tmp = vecn(args...); return V<decltype(tmp)>(val, tmp); } void Solve(); signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } void Solve() { li(r,c,n); ll xx1,yy1,xx2,yy2,vv1,vv2,k=0; vll x1,y1,x2,y2; vpl v; REP(i,n){ cin >> xx1 >> yy1 >> xx2 >> yy2; x1.pb(xx1); y1.pb(yy1); x2.pb(xx2); y2.pb(yy2); if(((xx1==0||xx1==r)||(yy1==0||yy1==c))&&((xx2==0||xx2==r)||(yy2==0||yy2==c))){ if(yy1==0){ vv1 = xx1; } else if (xx1==r) { vv1 = r + yy1; } else if (yy1==c) { vv1 = 2*r + c - xx1; } else if (xx1==0) { vv1 = 2*r + 2*c - yy1; } if(yy2==0){ vv2 = xx2; } else if (xx2==r) { vv2 = r + yy2; } else if (yy2==c) { vv2 = 2*r + c - xx2; } else if (xx2==0) { vv2 = 2*r + 2*c - yy2; } v.pb(mp(min(vv1,vv2),max(vv1,vv2))); } }`y SORT(v); REP(i,v.size()){ FOR(j,k,i-1){ if (v[j].se<=v[i].fi) { //k=max(k,j+1); } else if (v[j].se<v[i].se) { cout << "NO"; return; } } } cout << "YES"; return; }
a.cc:1230:4: error: stray '`' in program 1230 | }`y | ^ a.cc: In function 'void Solve()': a.cc:1230:5: error: 'y' was not declared in this scope 1230 | }`y | ^
s661182974
p03685
Java
import java.io.*; import java.math.*; import java.security.*; import java.text.*; public class Main { // Complete the minimumNumber function below. static int minimumNumber(int n, String password) { // Return the minimum number of characters to make the password strong return 1; } private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); int n = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); String password = scanner.nextLine(); int answer = minimumNumber(n, password); bufferedWriter.write(String.valueOf(answer)); bufferedWriter.newLine(); bufferedWriter.close(); scanner.close(); } }
Main.java:14: error: cannot find symbol private static final Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:14: error: cannot find symbol private static final Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors