제출 #90444

#제출 시각아이디문제언어결과실행 시간메모리
90444adletEvacuation plan (IZhO18_plan)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) using namespace std; typedef long long ll; const int LG = 17; const int N = 2e5 + 5; const int mod = 1e9 + 7; const int INF = 1e9; const double PI = acos(-1.0); struct item { int w, x, y; }; vector < item > e; int n, m, k, q, p[N], u[N], v[N], lvl[N], up[N][LG + 5], mn[N][LG + 5]; int d[N]; vector < pair < int, int > > g[N], g1[N]; int get(int v) { return (v == p[v] ? v : p[v] = get(p[v])); } int unite(int v, int u) { v = get(v); u = get(u); if (rand() & 1) swap(v, u); if (v != u) p[u] = v; } int solve(int s, int t) { if (lvl[s] < lvl[t]) swap(s, t); int ans = min(mn[s][0], mn[t][0]); for (int i = LG; i >= 0; --i) { if (up[s][i] > 0 && lvl[up[s][i]] >= lvl[t]) { ans = min(mn[s][i], ans); s = up[s][i]; } } if (s == t) return ans; for (int i = LG; i >= 0; --i) { if (lvl[up[s][i]] > 0 && lvl[up[t][i]] > 0 && up[s][i] != up[t][i]) { ans = min(mn[s][i], ans); ans = min(mn[t][i], ans); s = up[s][i]; t = up[t][i]; } } return min({ans, mn[s][0], mn[t][0]}); } bool cmp(item a, item b) { return a.w < b.w; } inline void dfs(int v, int p = 0, int len = INF) { up[v][0] = p; mn[v][0] = len; lvl[v] = lvl[p] + 1; for (int i = 1; i <= LG; ++i) { up[v][i] = up[up[v][i - 1]][i - 1]; mn[v][i] = min(mn[v][i - 1], mn[up[v][i - 1]][i - 1]); } for (auto node : g1[v]) { int to = node.first, lenn = node.second; if (p == to) continue; dfs(to, v, lenn); } } int main() { srand(time(NULL)); cin >> n >> m; for (int i = 1; i <= n; ++i) { d[i] = INF; p[i] = i; mn[i][0] = INF; } for (int i = 1; i <= m; ++i) { int w; cin >> u >> v >> w; g[v].push_back({u, w}); g[u].push_back({v, w}); } cin >> k; set < pair < int, int > > st; for (int i = 1, x; i <= k; ++i) { cin >> x; d[x] = 0; st.insert({0, x}); } while (!st.empty()) { int x = st.begin() -> second; st.erase(st.begin()); for (auto node : g[x]) { int to = node.first, len = node.second; if (d[to] > d[x] + len) { st.erase({d[to], to}); d[to] = d[x] + len; st.insert({d[to], to}); } } } for (int i = 1; i <= n; ++i) { for (auto node : g[i]) { int to = node.first; e.push_back({-1 * min(d[to], d[i]), i, to}); } } sort(e.begin(), e.end(), &cmp); for (auto ver : e) { int x = ver.x, y = ver.y; if (get(x) != get(y)) { g1[x].push_back({y, -ver.w}); g1[y].push_back({x, -ver.w}); unite(x, y); } } dfs(1); cin >> q; for (int i = 1; i <= q; ++i) { int s, t; cin >> s >> t; cout << solve(s, t) << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

plan.cpp: In function 'int unite(int, int)':
plan.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
plan.cpp: In function 'int main()':
plan.cpp:94:13: error: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'int [200005]')
         cin >> u >> v >> w;
         ~~~~^~~~
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:168:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(bool& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:168:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:172:7: note: candidate: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>] <near match>
       operator>>(short& __n);
       ^~~~~~~~
/usr/include/c++/7/istream:172:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'short int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(short int)((int*)(& u))' to 'short int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:175:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(unsigned short& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:175:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'short unsigned int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(short unsigned int)((int*)(& u))' to 'short unsigned int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:179:7: note: candidate: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>] <near match>
       operator>>(int& __n);
       ^~~~~~~~
/usr/include/c++/7/istream:179:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(int)((int*)(& u))' to 'int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:182:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(unsigned int& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:182:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'unsigned int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(unsigned int)((int*)(& u))' to 'unsigned int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:186:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(long& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:186:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'long int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(long int)((int*)(& u))' to 'long int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:190:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(unsigned long& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:190:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'long unsigned int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(long unsigned int)((int*)(& u))' to 'long unsigned int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:195:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(long long& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:195:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'long long int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(long long int)((int*)(& u))' to 'long long int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:199:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(unsigned long long& __n)
       ^~~~~~~~
/usr/include/c++/7/istream:199:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: invalid conversion from 'int*' to 'long long unsigned int' [-fpermissive]
         cin >> u >> v >> w;
                ^
plan.cpp:94:16: error: cannot bind rvalue '(long long unsigned int)((int*)(& u))' to 'long long unsigned int&'
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:235:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
       operator>>(void*& __p)
       ^~~~~~~~
/usr/include/c++/7/istream:235:7: note:   conversion of argument 1 would be ill-formed:
plan.cpp:94:16: error: cannot bind non-const lvalue reference of type 'void*&' to an rvalue of type 'void*'
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:120:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(__istream_type& (*__pf)(__istream_type&))
       ^~~~~~~~
/usr/include/c++/7/istream:120:7: note:   no known conversion for argument 1 from 'int [200005]' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}'
/usr/include/c++/7/istream:124:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
       operator>>(__ios_type& (*__pf)(__ios_type&))
       ^~~~~~~~
/usr/include/c++/7/istream:124:7: note:   no known conversion for argument 1 from 'int [200005]' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}'
/usr/include/c++/7/istream:131:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(ios_base& (*__pf)(ios_base&))
       ^~~~~~~~
/usr/include/c++/7/istream:131:7: note:   no known conversion for argument 1 from 'int [200005]' to 'std::ios_base& (*)(std::ios_base&)'
/usr/include/c++/7/istream:214:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(float& __f)
       ^~~~~~~~
/usr/include/c++/7/istream:214:7: note:   no known conversion for argument 1 from 'int [200005]' to 'float&'
/usr/include/c++/7/istream:218:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(double& __f)
       ^~~~~~~~
/usr/include/c++/7/istream:218:7: note:   no known conversion for argument 1 from 'int [200005]' to 'double&'
/usr/include/c++/7/istream:222:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long double& __f)
       ^~~~~~~~
/usr/include/c++/7/istream:222:7: note:   no known conversion for argument 1 from 'int [200005]' to 'long double&'
/usr/include/c++/7/istream:259:7: note: candidate: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
       operator>>(__streambuf_type* __sb);
       ^~~~~~~~
/usr/include/c++/7/istream:259:7: note:   no known conversion for argument 1 from 'int [200005]' to 'std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}'
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:45:0,
                 from plan.cpp:2:
/usr/include/c++/7/cstddef:134:5: note: candidate: template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(std::byte, _IntegerType)
     operator>>(byte __b, _IntegerType __shift) noexcept
     ^~~~~~~~
/usr/include/c++/7/cstddef:134:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: note:   cannot convert 'std::cin' (type 'std::istream {aka std::basic_istream<char>}') to type 'std::byte'
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/string:53:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/bits/basic_string.tcc:1465:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator>>(basic_istream<_CharT, _Traits>& __in,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.tcc:1465:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int [200005]'
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/istream:991:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/bits/istream.tcc:963:5: note: candidate: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
     ^~~~~~~~
/usr/include/c++/7/bits/istream.tcc:963:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: note:   deduced conflicting types for parameter '_CharT2' ('char' and 'int')
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/istream:991:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/bits/istream.tcc:931:5: note: candidate: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
     ^~~~~~~~
/usr/include/c++/7/bits/istream.tcc:931:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: note:   deduced conflicting types for parameter '_CharT' ('char' and 'int [200005]')
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:756:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     ^~~~~~~~
/usr/include/c++/7/istream:756:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: note:   cannot convert 'u' (type 'int [200005]') to type 'unsigned char&'
         cin >> u >> v >> w;
                ^
In file included from /usr/include/c++/7/sstream:38:0,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from plan.cpp:2:
/usr/include/c++/7/istream:761:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     ^~~~~~~~
/usr/include/c++/7/istream:761:5: note:   template argument deduction/substitution failed:
plan.cpp:94:16: not