submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s432437150
p04002
C++
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996) #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <queue> #include <functional> #include <sstream> #include <cmath> #include <set> #include <map> #include <stack> using namespace std; #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 pb push_back #define mp(a,b) make_pair(a,b) #define all(a) a.begin(),a.end() #define len(x) ((int)(x).size()) #define tmax(a,b,c) max((a),max((b),(c))) #define tmin(a,b,c) min((a),min((b),(c))) #define debug(x) cerr << #x << " is " << x << endl; typedef pair<int, int> Pii; typedef map<int, int> Mii; typedef vector<int> Vi; typedef vector<vector<int> > VVi; typedef long long ll; const int inf = 2e9; const ll ll_inf = 1e17; const int mod = 1e9 + 7; const long double eps = 1e-10; Mii m[100100100]; ll sum[11]; int main() { ll H, W, N; cin >> H >> W >> N; int h, w; sum[0] = (H-2)*(W-2); rep(i,0,N) { cin >> h >> w; h--; w--; rep(i,0,3) rep(j,0,3) { if (h-i >= 0 && h-i < H-2 && w-j >= 0 && w-j < W-2 ) { sum[m[h-i][w-j]]--; m[h-i][w-j]++; sum[m[h-i][w-j]]++; } } } rep(i,0,10) { cout << sum[i] << endl; } return 0; }
/tmp/ccaGq04O.o: in function `main': a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o a.cc:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o a.cc:(.text+0x268): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccaGq04O.o collect2: error: ld returned 1 exit status
s167693932
p04002
C
<?php class Scanner { private $arr = []; private $count = 0; private $pointer = 0; public function next() { if($this->pointer >= $this->count) { $str = trim(fgets(STDIN)); $this->arr = explode(' ', $str); $this->count = count($this->arr); $this->pointer = 0; } $result = $this->arr[$this->pointer]; $this->pointer++; return $result; } public function hasNext() { return $this->pointer < $this->count; } public function nextInt() { return (int)$this->next(); } public function nextDouble() { return (double)$this->next(); } } function check($y, $x) { } $sc = new Scanner(); $H = $sc->nextInt(); $W = $sc->nextInt(); $N = $sc->nextInt(); $map = array(); $a = array(); $b = array(); for($i=0;$i<$N;$i++) { $a[] = $sc->nextInt(); $b[] = $sc->nextInt(); $map[$a[$i]."_".$b[$i]] = 1; } $taboo = array(); $ans = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $dx = array(-1, 0, 1); $dy = array(-1, 0, 1); for($k=0;$k<$N;$k++) { //start($a[$i], $b[$i]); $yy = $a[$k]; $xx = $b[$k]; for($i=0;$i<3;$i++) { for($j=0;$j<3;$j++) { //check($y + $dy[$i], $x + $dx[$j]); $y = $yy + $dy[$i]; $x = $xx + $dx[$j]; if(isset($taboo[$y."_".$x])) continue; if($y <= 1 || $y >= $H || $x <= 1 || $x >= $W) continue; $taboo[$y."_".$x] = 1; //echo "check".$y.", ".$x."\n"; $count = 0; for($ii=0;$ii<3;$ii++) { for($jj=0;$jj<3;$jj++) { if(isset($map[($y+$dy[$ii])."_".($x+$dx[$jj])])) { $count++; } } } $ans[$count]++; } } } $sum = 0; for($i=1;$i<=9;$i++) { $sum += $ans[$i]; } $ans[0] = ($H * $W) - (2 * $H + 2 * $W) + 4 - $sum; for($i=0;$i<=9;$i++) { echo $ans[$i]."\n"; } ?>
main.c:1:1: error: expected identifier or '(' before '<' token 1 | <?php | ^ main.c:28:1: error: unknown type name 'function'; did you mean 'union'? 28 | function check($y, $x) { | ^~~~~~~~ | union main.c: In function 'check': main.c:28:10: error: type of '$y' defaults to 'int' [-Wimplicit-int] 28 | function check($y, $x) { | ^~~~~ main.c:28:10: error: type of '$x' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:32:1: warning: data definition has no type or storage class 32 | $sc = new Scanner(); | ^~~ main.c:32:1: error: type defaults to 'int' in declaration of '$sc' [-Wimplicit-int] main.c:32:7: error: 'new' undeclared here (not in a function) 32 | $sc = new Scanner(); | ^~~ main.c:32:11: error: expected ',' or ';' before 'Scanner' 32 | $sc = new Scanner(); | ^~~~~~~ main.c:33:1: warning: data definition has no type or storage class 33 | $H = $sc->nextInt(); | ^~ main.c:33:1: error: type defaults to 'int' in declaration of '$H' [-Wimplicit-int] main.c:33:9: error: invalid type argument of '->' (have 'int') 33 | $H = $sc->nextInt(); | ^~ main.c:34:1: warning: data definition has no type or storage class 34 | $W = $sc->nextInt(); | ^~ main.c:34:1: error: type defaults to 'int' in declaration of '$W' [-Wimplicit-int] main.c:34:9: error: invalid type argument of '->' (have 'int') 34 | $W = $sc->nextInt(); | ^~ main.c:35:1: warning: data definition has no type or storage class 35 | $N = $sc->nextInt(); | ^~ main.c:35:1: error: type defaults to 'int' in declaration of '$N' [-Wimplicit-int] main.c:35:9: error: invalid type argument of '->' (have 'int') 35 | $N = $sc->nextInt(); | ^~ main.c:36:1: warning: data definition has no type or storage class 36 | $map = array(); | ^~~~ main.c:36:1: error: type defaults to 'int' in declaration of '$map' [-Wimplicit-int] main.c:36:8: error: implicit declaration of function 'array' [-Wimplicit-function-declaration] 36 | $map = array(); | ^~~~~ main.c:36:8: error: initializer element is not constant main.c:37:1: warning: data definition has no type or storage class 37 | $a = array(); | ^~ main.c:37:1: error: type defaults to 'int' in declaration of '$a' [-Wimplicit-int] main.c:37:6: error: initializer element is not constant 37 | $a = array(); | ^~~~~ main.c:38:1: warning: data definition has no type or storage class 38 | $b = array(); | ^~ main.c:38:1: error: type defaults to 'int' in declaration of '$b' [-Wimplicit-int] main.c:38:6: error: initializer element is not constant 38 | $b = array(); | ^~~~~ main.c:40:1: error: expected identifier or '(' before 'for' 40 | for($i=0;$i<$N;$i++) { | ^~~ main.c:40:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 40 | for($i=0;$i<$N;$i++) { | ^ main.c:40:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 40 | for($i=0;$i<$N;$i++) { | ^~ main.c:46:1: warning: data definition has no type or storage class 46 | $taboo = array(); | ^~~~~~ main.c:46:1: error: type defaults to 'int' in declaration of '$taboo' [-Wimplicit-int] main.c:46:10: error: initializer element is not constant 46 | $taboo = array(); | ^~~~~ main.c:48:1: warning: data definition has no type or storage class 48 | $ans = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ^~~~ main.c:48:1: error: type defaults to 'int' in declaration of '$ans' [-Wimplicit-int] main.c:48:8: error: initializer element is not constant 48 | $ans = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ^~~~~ main.c:50:1: warning: data definition has no type or storage class 50 | $dx = array(-1, 0, 1); | ^~~ main.c:50:1: error: type defaults to 'int' in declaration of '$dx' [-Wimplicit-int] main.c:50:7: error: initializer element is not constant 50 | $dx = array(-1, 0, 1); | ^~~~~ main.c:51:1: warning: data definition has no type or storage class 51 | $dy = array(-1, 0, 1); | ^~~ main.c:51:1: error: type defaults to 'int' in declaration of '$dy' [-Wimplicit-int] main.c:51:7: error: initializer element is not constant 51 | $dy = array(-1, 0, 1); | ^~~~~ main.c:53:1: error: expected identifier or '(' before 'for' 53 | for($k=0;$k<$N;$k++) { | ^~~ main.c:53:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 53 | for($k=0;$k<$N;$k++) { | ^ main.c:53:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 53 | for($k=0;$k<$N;$k++) { | ^~ main.c:81:1: warning: data definition has no type or storage class 81 | $sum = 0; | ^~~~ main.c:81:1: error: type defaults to 'int' in declaration of '$sum' [-Wimplicit-int] main.c:82:1: error: expected identifier or '(' before 'for' 82 | for($i=1;$i<=9;$i++) { | ^~~ main.c:82:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token 82 | for($i=1;$i<=9;$i++) { | ^~ main.c:82:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 82 | for($i=1;$i<=9;$i++) { | ^~ main.c:86:1: warning: data definition has no type or storage class 86 | $ans[0] = ($H * $W) - (2 * $H + 2 * $W) + 4 - $sum; | ^~~~ main.c:86:1: error: type defaults to 'int' in declaration of '$ans' [-Wimplicit-int] main.c:86:1: error: conflicting types for '$ans'; have 'int[0]' main.c:48:1: note: previous definition of '$ans' with type 'int' 48 | $ans = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ^~~~ main.c:88:1: error: expected identifier or '(' before 'for' 88 | for($i=0;$i<=9;$i++) { | ^~~ main.c:88:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token 88 | for($i=0;$i<=9;$i++) { | ^~ main.c:88:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 88 | for($i=0;$i<=9;$i++) { | ^~ main.c:92:1: error: expected identifier or '(' before '?' token 92 | ?> | ^
s445882094
p04002
C++
#include <iostream> #include <map> #include <set> #include <algorithm> #include <cstdio> #define LL long long using namespace std; LL h, w, n; LL re[10]; set< pair<int ,int> > st; void f(int a, int b) { int num[3][3]; memset(num, -1, sizeof(num)); for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) { int x1 = a - 2 + i, y1 = b - 2 + j; int x2 = a + i, y2 = b + j; if(x1 < 0 || y1 < 0 || x2 >= h || y2 >= w) continue; num[i][j] = 0; } for(int i = max(a-2, 0); i <= min((LL)a+2, h-1); ++i) { for(int j = max(b-2, 0); j <= min((LL)b+2, w-1); ++j) { if(st.find( make_pair(i, j) ) != st.end() ) { for(int ii = 0; ii < 3; ++ii) for(int jj = 0; jj < 3; ++jj) { int x1 = a-2+ii, y1 = b-2+jj; int x2 = a + ii, y2 = b + jj; if(x1 < 0 || y1 < 0 || x2 >= h || y2 >= w) continue; if(i >= x1 && i <= x1+2 && j >= y1 && j <= y1+2) { if(num[ii][jj] == -1) num[ii][jj] = 1; else num[ii][jj] += 1; } } } } } for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) { //cout << a << " " << b << " " << i << " " << j << " " << num[i][j] << endl; if(num[i][j] == -1) continue; re[ num[i][j] ] --; re[ num[i][j] + 1] ++; } } int main(int argc, char* argv[]) { while(cin >> h >> w >> n) { st.clear(); memset(re, 0, sizeof(re)); re[0] = (h - 2) * (w - 2); for(LL i = 0; i < n; ++i) { int a, b; cin >> a >> b; --a, --b; f(a, b); st.insert( make_pair(a, b) ); } for(int i = 0; i < 10; ++i) { cout << re[i] << endl; } } return 0; }
a.cc: In function 'void f(int, int)': a.cc:15:5: error: 'memset' was not declared in this scope 15 | memset(num, -1, sizeof(num)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <cstdio> +++ |+#include <cstring> 6 | #define LL long long a.cc: In function 'int main(int, char**)': a.cc:51:9: error: 'memset' was not declared in this scope 51 | memset(re, 0, sizeof(re)); | ^~~~~~ a.cc:51:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s521493974
p04002
C++
#include<bits/stdc++.h> #include <unordered_map> using namespace std; pair<int,int> xy; unordered_map<pair<int,int>,int> board; int painted(int x,int y){ if(board[make_pair(x,y)]) return 1; return 0; } int howmany(int x,int y){ int ans=0; for(int i=x-1;i<=x+1;i++){ for(int j=y-1;j<=y+1;j++){ if(painted(i,j)) ans++; } } return ans; } long long qnt[20]; int main(){ long long h,w,n; cin>>h>>w>>n; qnt[0]=(h-2)*(w-2); for(int q=1;q<=n;q++){ int a,b; scanf("%d%d",&a,&b); int up=a-1; int down=a+1; int left=b-1; int right =b+1; if(up<2) up=2; if(down>h-1) down=h-1; if(left<2) left=2; if(right>w-1) right=w-1; for(int i=up;i<=down;i++){ for(int j=left;j<=right;j++){ qnt[howmany(i,j)]--; qnt[howmany(i,j)+1]++; } } board[make_pair(a,b)]++; } for(int i=0;i<=9;i++){ cout<<qnt[i]<<endl; } }
a.cc:5:34: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 5 | unordered_map<pair<int,int>,int> board; | ^~~~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<const std
s844961405
p04002
C++
#include <iostream> #include <sstream> #include <algorithm> #include <string> #include <array> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <memory> #include <complex> #include <numeric> #include <cstdio> #include <iomanip> #define REP(i,m,n) for(int i=int(m);i<int(n);i++) #define EACH(i,c) for (auto &(i): c) #define all(c) begin(c),end(c) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(begin(c),end(c)) #define pb emplace_back #define MP make_pair #define SZ(a) int((a).size()) #ifdef LOCAL #define DEBUG(s) cout << (s) << endl #define dump(x) cerr << #x << " = " << (x) << endl #define BR cout << endl; #else #define DEBUG(s) do{}while(0) #define dump(x) do{}while(0) #define BR #endif using namespace std; using UI = unsigned int; using UL = unsigned long; using LL = long long int; using ULL = unsigned long long; using VI = vector<int>; using VVI = vector<VI>; using VLL = vector<LL>; using VS = vector<string>; using PII = pair<int,int>; using VP = vector<PII>; //struct edge {int from, to, cost;}; constexpr double EPS = 1e-10; constexpr double PI = acos(-1.0); //constexpr int INF = INT_MAX; template<class T> inline T sqr(T x) {return x*x;} struct Pos { int x,y; Pos(int a, int b) { x = a; y = b; } Pos() {} bool operator==(const Pos &right) { return x == right.x && y == right.y; } bool operator!=(const Pos &right) { return !(*this == right); } }; vector<Pos> mita; array<Pos, 100000> black; //Pos mita[100000*8], black[100000]; int n; int countblack(int x, int y) { int ret = 0; for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { if (find(begin(black), begin(black)+n, Pos(x+i,y+j)) != begin(black)+n) { ++ret; } } } // mita.emplace_back(x,y); //cout << x << " " << y << " " << ret << endl; return ret; } // 0 1 2 ... len-3 len-2 len-1 int main() { int h, w; LL ans[10] = {}; cin >> h >> w >> n; int a, b; REP(i,0,n) { cin >> a >> b; black[i].x = a-1; black[i].y = b-1; //mita[i].x = a; //mita[i].y = b; //mita.emplace_back(a,b); } sort(begin(black), begin(black)+n); REP(i,0,n) { for (int x = black[i].x-1; x <= black[i].x+1; ++x) { for (int y = black[i].y-1; y <= black[i].y+1; ++y) { //if (x >= 1 && x <= w-2 && y >= 1 && y <= h-2 && find(all(mita), Pos(x,y)) == end(mita)) { if (x >= 1 && x <= h-2 && y >= 1 && y <= w-2 && find(all(mita), Pos(x,y)) == end(mita)) { int ret = countblack(x,y); if (ret > 1) { mita.emplace_back(x,y); } ans[ret]++; } } } } REP(i,0,10) { if (i != 0 || true) cout << ans[i] << endl; else { cout << (LL)(h - 2) * (w - 2) - ans[1] - ans[2] - ans[3] - ans[4] - ans[5] - ans[6] - ans[7] - ans[8] - ans[9] << endl; } } return 0; }
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 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = Pos*; _Iterator2 = Pos*]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = Pos*]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:105:6: required from here 105 | sort(begin(black), begin(black)+n); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'Pos' and 'Pos') 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'Pos' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'Pos' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = Pos; _Iterator = Pos*]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = Pos*; _Compare = __gnu_cxx::__ops::_Val_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = Pos*]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:105:6: required from here 105 | sort(begin(black), begin(black)+n); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'Pos' and 'Pos') 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'Pos' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'Pos' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = Pos*; _Value = Pos]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = Pos*; _Distance = long int; _Tp = Pos; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 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 = Pos*; _Distance = long int; _Tp = Pos; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 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 = Pos*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_a
s334384172
p04002
Java
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class MainB { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { long H = sc.nextLong(); long W = sc.nextLong(); int N = sc.nextInt(); long all = (H - 2) * (W - 2); Map<String, Integer> map = new HashMap<>(); while (N-- > 0) { int h = sc.nextInt() - 1; int w = sc.nextInt() - 1; for (int i = -2; i <= 0; i++) { for (int j = -2; j <= 0; j++) { boolean f = true; int ph = h + j; int pw = w + i; L: for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { if (!inner(ph + k, pw + l, H, W)) { f = false; break L; } } } if (f) { StringBuilder k = new StringBuilder(); k.append(ph); k.append("_"); k.append(pw); map.put(k.toString(), map.containsKey(k.toString()) ? map.get(k.toString()) + 1 : 1); } } } } long[] a = new long[10]; int cnt = 0; for(String key : map.keySet()) { a[map.get(key)]++; cnt++; } a[0] = all - cnt; for(long res : a) System.out.println(res); } public static void main(String[] args) { new MainB().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(char[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } boolean inner(int h, int w, long limH, long limW) { return 0 <= h && h < limH && 0 <= w && w < limW; } void swap(int[] x, int a, int b) { int tmp = x[a]; x[a] = x[b]; x[b] = tmp; } // find minimum i (k <= a[i]) int lower_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k <= a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } // find minimum i (k < a[i]) int upper_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k < a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } long gcd(long a, long b) { return a % b == 0 ? b : gcd(b, a % b); } long lcm(long a, long b) { return a * b / gcd(a, b); } boolean palindrome(String s) { for (int i = 0; i < s.length() / 2; i++) { if (s.charAt(i) != s.charAt(s.length() - 1 - i)) { return false; } } return true; } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } int[] nextIntArray(int n) { int[] in = new int[n]; for (int i = 0; i < n; i++) { in[i] = nextInt(); } return in; } int[][] nextInt2dArray(int n, int m) { int[][] in = new int[n][m]; for (int i = 0; i < n; i++) { in[i] = nextIntArray(m); } return in; } double[] nextDoubleArray(int n) { double[] in = new double[n]; for (int i = 0; i < n; i++) { in[i] = nextDouble(); } return in; } long[] nextLongArray(int n) { long[] in = new long[n]; for (int i = 0; i < n; i++) { in[i] = nextLong(); } return in; } char[][] nextCharField(int n, int m) { char[][] in = new char[n][m]; for (int i = 0; i < n; i++) { String s = sc.next(); for (int j = 0; j < m; j++) { in[i][j] = s.charAt(j); } } return in; } } }
Main.java:6: error: class MainB is public, should be declared in a file named MainB.java public class MainB { ^ 1 error
s221400957
p04003
C++
#include "atcoder/all" #include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 2147483647 / 2; const long long int llINF = 9223372036854775807 / 2; using namespace std; using namespace atcoder; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using tupll = tuple<ll, ll, ll>; typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) #define VVV(T, a, b, c, d) \ vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d))) #define SP(a) fixed << setprecision(a) #define SQRT(a) sqrt((long double)(a)) #define DPOW(a, b) pow((long double)(a), (long double)(b)) #define UNIQUE(vec) \ do { \ sort(ALL((vec))); \ (vec).erase(std::unique(ALL((vec))), (vec).end()); \ } while (0) ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll N, M; cin >> N >> M; vector<vector<pll>> G(N); REP(i, M) { ll p, q, c; cin >> p >> q >> c; p--; q--; c--; G[p].push_back({q, c}); G[q].push_back({p, c}); } PQ(tupll) Q; Q.push({0, 0, -1}); map<pll, ll> DP; // vl DP(N + 1, llINF); DP[{0, -1}] = 0; while (!Q.empty()) { auto q = Q.top(); Q.pop(); ll cost = get<0>(q); ll now = get<1>(q); ll com = get<2>(q); AUTO(g, G[now]) { ll n_cost = cost; if (com != g.second) n_cost++; if (DP.count({g.first, g.second}) == 0 || DP[g] > n_cost) { DP[g] = n_cost; Q.push({n_cost, g.first, g.second}); } } } ll ans = llINF; REP(i, 1e6) { if (DP.count({N - 1, i}) != 0) ans = min(ans, DP[{N - 1, i}]); } if (ans == llINF) cout << -1 << endl; else cout << ans << endl; return 0; }
a.cc:1:10: fatal error: atcoder/all: No such file or directory 1 | #include "atcoder/all" | ^~~~~~~~~~~~~ compilation terminated.
s267458895
p04003
C++
#include "atcoder/all" #include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 2147483647 / 2; const long long int llINF = 9223372036854775807 / 2; using namespace std; using namespace atcoder; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using tupll = tuple<ll, ll, ll>; typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) #define VVV(T, a, b, c, d) \ vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d))) #define SP(a) fixed << setprecision(a) #define SQRT(a) sqrt((long double)(a)) #define DPOW(a, b) pow((long double)(a), (long double)(b)) #define UNIQUE(vec) \ do { \ sort(ALL((vec))); \ (vec).erase(std::unique(ALL((vec))), (vec).end()); \ } while (0) ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll N, M; cin >> N >> M; vector<vector<pll>> G(N); REP(i, M) { ll p, q, c; cin >> p >> q >> c; p--; q--; c--; G[p].push_back({q, c}); G[q].push_back({p, c}); } PQ(tupll) Q; Q.push({0, 0, -1}); map<pll, ll> DP; // vl DP(N + 1, llINF); DP[{0, -1}] = 0; while (!Q.empty()) { auto q = Q.top(); Q.pop(); ll cost = get<0>(q); ll now = get<1>(q); ll com = get<2>(q); AUTO(g, G[now]) { ll n_cost = cost; if (com != g.second) n_cost++; if (DP.count({g.first, g.second}) == 0 || DP[g] > n_cost) { DP[g] = n_cost; Q.push({n_cost, g.first, g.second}); } } } ll ans = llINF; REP(i, 1e6) { if (DP.count({N - 1, i}) != 0) ans = min(ans, DP[{N - 1, i}]); } if (ans == llINF) cout << -1 << endl; else cout << ans << endl; return 0; }
a.cc:1:10: fatal error: atcoder/all: No such file or directory 1 | #include "atcoder/all" | ^~~~~~~~~~~~~ compilation terminated.
s869080515
p04003
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n, m; cin >> n >> m; vector<vector<pair<int, int> > >edge(n + 3); vector<vector<int> >rails(n + 3); for(int i = 1; i <= m; i++){ int u, v, c; cin >> u >> v >> c; edge[u].push_back({c, v}); edge[v].push_back({c, u}); rails[u].push_back(c); rails[v].push_back(c); } for(int i = 1; i <= n; i++){ sort(edge[i].begin(), edge[i].end()); } deque<pair<int, pair<int, int> > >dq; vector<map<int, int> >mp(n + 3); mp[1][0] = 0; dq.push_back({0, {1, 0}}); while(!dq.empty()){ int d = dq.front().first; int now = dq.front().second.first; int rail = dq.front().second.second; dq.pop_front(); if(rail == 0){ for(int i = 0; i < rails[now].size(); i++){ int nrail = rails[now][i]; if(mp[now].find(nrail) != mp[now].end() && mp[now][nrail] <= d + 1){ continue; } mp[now][nrail] = d + 1; dq.push_back({d + 1, {now, nrail}}); } } else{ pair<int, int>p = make_pair(rail, 0); int x = lower_bound(edge[now].begin(), edge[now].end(), p) - edge[now].begin(); while(x != edge[now].size() && edge[now][x].first == rail){ int nxt = edge[now][x].second; if(mp[nxt].find(rail) != mp[nxt].end() && mp[nxt][rail] <= d){ x++; continue; } mp[nxt][rail] = d; dq.push_front({d, {nxt, rail}}); x++; } if(mp[now].find(0) != mp[now].end() && mp[now][0] <= d){ continue; } mp[now][0] = d; dq.push_front({d, {now, 0}}); } } if(mp[n].empty()){ cout << "-1"; return 0; } int ans = 1e8; for(int i = 0; i < rails[n].size(); i++){ int x = rails[n][i]; ans = min(ans, mp[n][x]); } else{ cout << ans; } return 0; }
a.cc: In function 'int main()': a.cc:67:5: error: 'else' without a previous 'if' 67 | else{ | ^~~~
s893224629
p04003
C++
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include<bits/stdc++.h> using namespace std; const int N=1e5+5; struct Edge{ int t,nxt,w; }e[N<<2]; int cnt,head[N]; inline void add(int u,int v,int w){ e[++cnt].nxt=head[u]; e[cnt].t=v; e[cnt].w=w; head[u]=cnt; } char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf; #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) inline int rd() { int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();} while(isdigit(ch)) x=x*10+(ch^48),ch=getchar(); return x*f; } set<int> st[N]; int vis[N],n,m,dis[N]; int dij(){ memset(dis,0x3f,sizeof dis); priority_queue< pair<int,int > >q; q.push(make_pair(0,1)); dis[1]=0; while (!q.empty()){ int u=q.top().second; q.pop(); if (vis[u]) continue; vis[u]=1; for (int i=head[u];i;i=e[i].nxt){ int v=e[i].t,w=1; if (st[u].count(e[i].w)) w=0; if (dis[u]+w<dis[v]){ dis[v]=dis[u]+w; st[v].clear(); st[v].insert(e[i].w); q.push(make_pair(-dis[v],v)); }else if (dis[u]+w==dis[v]) { if (!st[v].count(e[i].w)){ st[v].insert(e[i].w); q.push(make_pair(-dis[v],v)); vis[v]=0; } } } } if (dis[n]>1e9) return -1; else return dis[n]; } int main(){ n=rd();m=rd(); int u,v,w; for (int i=1;i<=m;++i){ u=rd(); v=rd(); w=rd(); add(u,v,w); add(v,u,w); } printf("%d\n",dij()); }
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:4: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_Rb_tree_impl<std::less<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<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 | ^~~~~~~~~~~~~
s039845906
p04003
Java
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; public class Main { public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int m = sc.nextInt(); HashMap<Edge, Integer> map = new HashMap<>(); ArrayList<Edge>[] adj= new ArrayList[n]; for(int i=0;i<n;i++) { adj[i] = new ArrayList<>(); } for(int i=0;i<m;i++) { int p = sc.nextInt()-1; int q = sc.nextInt()-1; int c = sc.nextInt()-1; adj[p].add(new Edge(q,c)); adj[q].add(new Edge(p,c)); } HashMap<Edge, Integer> dp = new HashMap<Edge, Integer>(); LinkedList<Edge> pq = new LinkedList<>(); for(Edge x : adj[0]) { dp.put(x,1); pq.add(x); } while(!pq.isEmpty()) { Edge curr = pq.poll(); int steps = dp.get(curr); for(Edge next : adj[curr.dest]) { if(next.c==curr.c) { if(steps<dp.getOrDefault(next,1000000000)) { dp.put(next, steps); pq.addFirst(next); } } else { if(steps+1<dp.getOrDefault(next,1000000000)) { dp.put(next,steps+1); pq.addLast(next); } } } } int min = 1000000000; for(int c=0;c<1000000;c++) { min = Math.min(min,dp.getOrDefault(new Edge(n-1,c),1000000000)); } if(min>=1000000000) { System.out.println(-1); } else { System.out.println(min); } } static class Edge{ int dest; int c; public Edge(int dest,int c) { this.dest = dest; this.c = c; } @Override public int hashCode() { return dest*1299827+c*1299821; } @Override public boolean equals(Object o) { Edge e = (Edge)o; return (e.dest==dest && e.c==c); } } } class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
Main.java:84: error: cannot find symbol BufferedReader br; ^ symbol: class BufferedReader location: class MyScanner Main.java:85: error: cannot find symbol StringTokenizer st; ^ symbol: class StringTokenizer location: class MyScanner Main.java:88: error: cannot find symbol br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class MyScanner Main.java:88: error: cannot find symbol br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class MyScanner Main.java:94: error: cannot find symbol st = new StringTokenizer(br.readLine()); ^ symbol: class StringTokenizer location: class MyScanner Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors
s695559406
p04003
Java
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; public class Main { public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int m = sc.nextInt(); HashMap<Edge, Integer> map = new HashMap<>(); ArrayList<Edge>[] adj= new ArrayList[n]; for(int i=0;i<n;i++) { adj[i] = new ArrayList<>(); } for(int i=0;i<m;i++) { int p = sc.nextInt()-1; int q = sc.nextInt()-1; int c = sc.nextInt()-1; adj[p].add(new Edge(q,c)); adj[q].add(new Edge(p,c)); } HashMap<Edge, Integer> dp = new HashMap<Edge, Integer>(); LinkedList<Edge> pq = new LinkedList<>(); for(Edge x : adj[0]) { dp.put(x,1); pq.add(x); } while(!pq.isEmpty()) { Edge curr = pq.poll(); int steps = dp.get(curr); for(Edge next : adj[curr.dest]) { if(next.c==curr.c) { if(steps<dp.getOrDefault(next,1000000000)) { dp.put(next, steps); pq.addFirst(next); } } else { if(steps+1<dp.getOrDefault(next,1000000000)) { dp.put(next,steps+1); pq.addLast(next); } } } } int min = 1000000000; for(int c=0;c<1000000;c++) { min = Math.min(min,dp.getOrDefault(new Edge(n-1,c),1000000000)); } if(min>=1000000000) { System.out.println(-1); } else { System.out.println(min); } } static class Edge{ int dest; int c; public Edge(int dest,int c) { this.dest = dest; this.c = c; } @Override public int hashCode() { return dest*1299827+c*1299821; } @Override public boolean equals(Object o) { Edge e = (Edge)o; return (e.dest==dest && e.c==c); } } } class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
Main.java:84: error: cannot find symbol BufferedReader br; ^ symbol: class BufferedReader location: class MyScanner Main.java:85: error: cannot find symbol StringTokenizer st; ^ symbol: class StringTokenizer location: class MyScanner Main.java:88: error: cannot find symbol br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class MyScanner Main.java:88: error: cannot find symbol br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class MyScanner Main.java:94: error: cannot find symbol st = new StringTokenizer(br.readLine()); ^ symbol: class StringTokenizer location: class MyScanner Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors
s557023962
p04003
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.PriorityQueue; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Reader sc = new Reader(); int n = sc.nextInt(); int m = sc.nextInt(); HashMap<Edge, Integer> map = new HashMap<>(); ArrayList<Edge>[] adj= new ArrayList[n]; for(int i=0;i<n;i++) { adj[i] = new ArrayList<>(); } for(int i=0;i<m;i++) { int p = sc.nextInt()-1; int q = sc.nextInt()-1; int c = sc.nextInt()-1; adj[p].add(new Edge(q,c)); adj[q].add(new Edge(p,c)); } HashMap<Edge, Integer> dp = new HashMap<Edge, Integer>(); PriorityQueue<Edge> pq = new PriorityQueue<>(new Comparator<Edge>() { @Override public int compare(Edge o1, Edge o2) { // TODO Auto-generated method stub return dp.get(o1)-dp.get(o2); } }); for(Edge x : adj[0]) { dp.put(x,1); pq.add(x); } while(!pq.isEmpty()) { Edge curr = pq.poll(); int steps = dp.get(curr); for(Edge next : adj[curr.dest]) { if(next.c==curr.c) { if(steps<dp.getOrDefault(next,1000000000)) { dp.put(next, steps); pq.add(next); } } else { if(steps+1<dp.getOrDefault(next,1000000000)) { dp.put(next,steps+1); pq.add(next); } } } } int min = 1000000000; for(int c=0;c<1000000;c++) { min = Math.min(min,dp.getOrDefault(new Edge(n-1,c),1000000000)); } if(min>=1000000000) { System.out.println(-1); } else { System.out.println(min); } } static class Edge{ int dest; int c; public Edge(int dest,int c) { this.dest = dest; this.c = c; } @Override public int hashCode() { return dest*1299827+c*1299821; } @Override public boolean equals(Object o) { Edge e = (Edge)o; return (e.dest==dest && e.c==c); } } static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') break; buf[cnt++] = (byte) c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } }
Main.java:93: error: cannot find symbol private DataInputStream din; ^ symbol: class DataInputStream location: class Reader Main.java:99: error: cannot find symbol din = new DataInputStream(System.in); ^ symbol: class DataInputStream location: class Reader Main.java:106: error: cannot find symbol din = new DataInputStream(new FileInputStream(file_name)); ^ symbol: class DataInputStream location: class Reader Main.java:106: error: cannot find symbol din = new DataInputStream(new FileInputStream(file_name)); ^ symbol: class FileInputStream location: class Reader Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors
s525389240
p04003
C++
1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^
s316518663
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef tuple<int,int,int> piii; const int INF=1000000000; #define endl "\n" #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); #define all(x) (x).begin(), (x).end() #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, M; cin >> N >> M; vector<int> dist(N+1,INF); dist[1]=0; vector<vector<pii>> adj(N+1); set <piii, greater<piii>> checker; int a,b,c; for (int i=0; i<M; i++){ cin >> a >> b >> c; adj[a].push_back(make_pair(b,c)); adj[b].push_back(make_pair(a,c)); } priority_queue<piii,vector<piii>,greater<piii>> pq; piii temp=make_tuple(0,1,-1); piii temp2; int curr=0; pii t; pq.push(temp); while (!pq.empty()){ //printy(checker); //rese(dist); temp=pq.top(); pq.pop(); for (int i=0; i<adj[get<1>(temp)].size(); i++){ t=adj[get<1>(temp)][i]; curr=get<0>(temp); if (t.second!=get<2>(temp)) curr++; temp2=make_tuple(get<1>(temp),t.first,t.second) if (dist[t.first]>curr or (dist[t.first]==curr and checker.find(temp2)==checker.end()) ){ dist[t.first]=curr; checker.insert(temp2); // temp2.distance=curr; // temp2.node=t.first; // temp2.company=t.second; pq.push(make_tuple(curr,t.first,t.second)); } } } if (dist[N]==INF) dist[N]=-1; cout<<dist[N]<<endl; }
a.cc: In function 'int main()': a.cc:61:54: error: expected ';' before 'if' 61 | temp2=make_tuple(get<1>(temp),t.first,t.second) | ^ | ; 62 | 63 | if (dist[t.first]>curr or (dist[t.first]==curr and checker.find(temp2)==checker.end()) ){ | ~~
s707278249
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef tuple<int,int,int> piii; const int INF=10000000; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, M; cin >> N >> M; vector<int> dist(N+1,INF); dist[1]=0; vector<vector<pii>> adj(N+1); int a,b,c; for (int i=0; i<M; i++){ cin >> a >> b >> c; adj[a].push_back(make_pair(b,c)); adj[b].push_back(make_pair(a,c)); } priority_queue<piii,vector<piii>,greater<piii>> pq; //dist,node,company piii temp=make_tuple(0,1,-1); pii t; pq.push(temp); while (!pq.empty()){ temp=pq.top(); pq.pop(); curr=get<0>(temp); // distance for (int i=0; i<adj[get<1>(temp)].size(); i++){ t=adj[get<1>(temp)][i]; // distance if (t.second!=get<2>(temp)) curr++; if (dist[t.first]>=curr){ dist[t.first]=curr; // temp2.distance=curr; // temp2.node=t.first; // temp2.company=t.second; pq.push(make_tuple(curr,t.first,t.second)); } } } if (dist[N]==INF) dist[N]=-1; cout<<dist[N]<<endl; }
a.cc: In function 'int main()': a.cc:41:5: error: 'curr' was not declared in this scope 41 | curr=get<0>(temp); // distance | ^~~~
s618087577
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef tuple<int,int,int> piii; const int INF=10000000; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, M; cin >> N >> M; vector<int> dist(N+1,INF); dist[1]=0; vector<vector<pii>> adj(N+1); int a,b,c; for (int i=0; i<M; i++){ cin >> a >> b >> c; adj[a].push_back(make_pair(b,c)); adj[b].push_back(make_pair(a,c)); } priority_queue<piii,vector<piii>,greater<piii>> pq; piii temp=make_tuple(0,1,-1); pii t; pq.push(temp); while (!pq.empty()){ //rese(dist); temp=pq.top(); pq.pop(); for (int i=0; i<adj[temp.node].size(); i++){ t=adj[get<1>(temp)][i]; curr=get<0>(temp); if (t.second!=get<2>(temp)) curr++; if (dist[t.first]>curr){ dist[t.first]=curr; // temp2.distance=curr; // temp2.node=t.first; // temp2.company=t.second; pq.push(make_tuple(curr,t.first,t.second)); } } } cout<<dist[N]<<endl; }
a.cc: In function 'int main()': a.cc:42:30: error: 'piii' {aka 'class std::tuple<int, int, int>'} has no member named 'node' 42 | for (int i=0; i<adj[temp.node].size(); i++){ | ^~~~ a.cc:44:7: error: 'curr' was not declared in this scope 44 | curr=get<0>(temp); | ^~~~
s033885922
p04003
C++
#include<bits/stdc++.h> using namespace std; const int MAXN=1e5+6; int n,m,ans=(int)1e9; vector<pair<int,int> >g[MAXN]; unordered_map<pair<int,int>,int>mp; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for(int i=0;i<m;i++) { int p,q,c; cin>>p>>q>>c; g[p].push_back({q,c}); g[q].push_back({p,c}); } mp[{1,-1}]=0; deque<pair<int,int> >dq; dq.push_back({1,-1}); while(!dq.empty()) { pair<int,int> u=dq.front(); //cout<<u.first<<" "<<u.second<<endl; if(u.first==n)ans=min(ans,mp[u]); dq.pop_front(); for(int i=0;i<g[u.first].size();++i) { pair<int,int> t=g[u.first][i]; if(mp.count(t)&&mp[u]+(t.second!=u.second)>=mp[t])continue; mp[t]=mp[u]+(t.second!=u.second); if(t.second==u.second) { dq.push_front(t); } else dq.push_back(t); } } if(ans==1000000000) { cout<<"-1\n"; return 0; } cout<<ans<<endl; return 0; }
a.cc:6:33: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 6 | unordered_map<pair<int,int>,int>mp; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<const std::pair<i
s132691521
p04003
C++
#include<bits/stdc++.h> using namespace std; const int MAXN=1e5+6; int n,m,ans=(int)1e9; vector<pair<int,int> >g[MAXN]; map<pair<int,int>,int>mp; int main() { cin>>n>>m; for(int i=0;i<m;i++) { int p,q,c; cin>>p>>q>>c; g[p].push_back({q,c}); g[q].push_back({p,c}); } mp[{1,-1}]=0; deque<pair<int,int> >dq; dq.push_back({1,-1}); while(!dq.empty()) { pair<int,int> u=dq.front(); //cout<<u.first<<" "<<u.second<<endl; if(u.first==n)ans=min(ans,mp[u]); dq.pop_front(); for(int i=0;i<g[u.first].size();i++) { pair<int,int> t=g[u.first][i]; if(mp.count(t)&&mp[u]+(t.second!=u.second)>=mp[t])continue; mp[t]=mp[u]+(t.second!=u.second); if(t.second==u.second) { dq.push_front(t); } else dq.push_back(t); } } if(as==1000000000) { cout<<"-1\n"; return 0; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:8: error: 'as' was not declared in this scope; did you mean 'ans'? 38 | if(as==1000000000) | ^~ | ans
s284226337
p04003
C++
//#pragma GCC optimize("Ofast") #include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include <fstream> #include <time.h> #define REP(i, n) for(int i = 0;i < n;++i) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;++i) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); //#define int long long #define all(x) (x).begin(), (x).end() using namespace std; int MAX = 100010; int MOD = (ll)1000000000 + 7; ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pair<ll, int>P;//firstは距離、secondは頂点番号 struct Ver { ll dist; unordered_set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる struct edge { int to, cmp; };//辺には行き先の頂点と会社を持たせる Ver d[100010]; int V;//頂点数 int M;//辺の本数 vector<edge>G[100010];//グラフ //int d[MAX];//始点からの距離 void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; set<int>st;//キューに入っている頂点番号 //全点への距離をINFで初期化 for (int i = 0; i < V + 1; ++i) { d[i].dist = INF; } //始点への距離は0 d[s].dist = 0; //始点をキューに入れる que.push(P(0, s)); st.insert(s); while (!que.empty()) { P p = que.top(); que.pop(); auto c = st.erase(p.second); int v = p.second;//今見ている頂点 if (d[v].dist < p.first)continue; //今見ている頂点につながるすべての辺について距離を更新する int n = G[v].size(); for (int i = 0; i < n; ++i) { edge e = G[v][i]; int cost = 1; //vに訪れるのに最後に使った会社(複数の場合もある)が今見ている辺の会社と同じならコストを0にする if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; //今見ている辺を使うことでe.toへの距離が小さくなるなら、距離を更新し、最後に使った会社をe.cmpとする if (d[e.to].dist > d[v].dist + cost) { d[e.to] = { d[v].dist + cost,{ e.cmp } }; que.push(P(d[e.to].dist, e.to)); st.insert(e.to); } //今見ている辺を使っても距離が変わらない場合、最後に使った会社に(もしe.cmpがなかったら)e.cmpを追加する else if (d[e.to].dist == d[v].dist + cost) { if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { d[e.to].company.insert(e.cmp); if (st.find(e.to) == st.end()) { que.push(P(d[e.to].dist, e.to)); st.insert(e.to); } } } } } } int main() { cin >> V >> M; int p, q, c; for (int i = 0; i < M; i++) { scanf("%d %d %d", &p, &q, &c); G[p].push_back({ q,c }); G[q].push_back({ p,c }); } dijkstra(1); ll ans = d[V].dist; if (ans == INF) { cout << -1 << endl; return 0; } cout << ans << endl; }
a.cc:50:23: error: 'unordered_set' does not name a type 50 | struct Ver { ll dist; unordered_set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる | ^~~~~~~~~~~~~ a.cc: In function 'void dijkstra(int)': a.cc:81:34: error: 'struct Ver' has no member named 'company' 81 | if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; | ^~~~~~~ a.cc:81:62: error: 'struct Ver' has no member named 'company' 81 | if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; | ^~~~~~~ a.cc:84:72: error: no match for 'operator=' (operand types are 'Ver' and '<brace-enclosed initializer list>') 84 | d[e.to] = { d[v].dist + cost,{ e.cmp } }; | ^ a.cc:50:8: note: candidate: 'constexpr Ver& Ver::operator=(const Ver&)' 50 | struct Ver { ll dist; unordered_set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる | ^~~ a.cc:50:8: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const Ver&' a.cc:50:8: note: candidate: 'constexpr Ver& Ver::operator=(Ver&&)' a.cc:50:8: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'Ver&&' a.cc:89:45: error: 'struct Ver' has no member named 'company' 89 | if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { | ^~~~~~~ a.cc:89:76: error: 'struct Ver' has no member named 'company' 89 | if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { | ^~~~~~~ a.cc:90:49: error: 'struct Ver' has no member named 'company' 90 | d[e.to].company.insert(e.cmp); | ^~~~~~~
s350814660
p04003
C++
#include<bits/stdc++.h> using namespace std; const int N = 1e5+5; vector<pair<int,int>> g[N]; bool vis[N]; int ans = N; int n,m; void dfs(int x, int c,int prev){ vis[x] = true; if(x == n-1){ ans = min(ans,c); return ; } for(auto to : g[x]){ if(vis[to.first]) continue; if(prev!=to.second) dfs(to.first,c+1,to.second); else dfs(to.first,c,to.second); vis[to.first] = false; } } int main(){ cin>>n>>m; for(int i = 0; i < m; i++){ int p,q,c; cin>>p>>q>>c; --p,--q; g[p].push_back({q,c}); g[q].push_back({p,c}); } dfs(0,0,0); if(ans == N) cout<<-1; else cout<<ans }
a.cc: In function 'int main()': a.cc:37:19: error: expected ';' before '}' token 37 | else cout<<ans | ^ | ; 38 | } | ~
s109080176
p04003
C++
#include <bits\stdc++.h> using namespace std; typedef pair<int, int> pi; int inf=1e9; int n, m; map<pi, int> mp; pi po[500000]; int d[500000]; priority_queue<pi> pq; bool operator < (pi a, pi b) { return a.first>b.first; } vector<int> g[500000]; vector<int> g1[500000]; int cnt=0, ans=inf; void dij() { for (int i=0; i<2*n; i++) d[i]=inf; for (int i=0; i<g[1].size(); i++) { int u=g[1][i]; d[u]=0; pq.push({d[u], u}); } while(!pq.empty()) { pi x= pq.top(); pq.pop(); if (d[x.second]!=x.first) continue; pi u=po[x.second]; //cout << u.first << ' ' << u.second << ' ' << x.first << endl; for (int i=0; i<g1[u.first].size(); i++) { int v= g1[u.first][i]; for (int j=0; j<g[v].size(); j++) { int v0= g[v][j]; int e = !(u.second == po[v0].second); if (d[x.second]+ e < d[v0]) { //cout << u.first << ' ' << u.second << ' ' << x.first << ' ' << po[v0].first << ' ' << po[v0].second ; d[v0]= d[x.second]+ e; pq.push({d[v0], v0}); //cout << ' ' << d[v0] << endl; if (po[v0].first== n) { ans=min(ans, d[v0]); //cout << ans << endl; //cout << po[v0].first << ' ' << po[v0].second << endl; } } } } } } int main() { cin>>n>>m; for (int i=0; i<m; i++) { int x, y, z; cin>>x>>y>>z; if (!mp[pi{x, z}]) { mp[pi{x, z}]=++cnt; po[cnt]=pi{x, z}; g[x].push_back(cnt); } if (!mp[pi{y, z}]) { mp[pi{y, z}]=++cnt; po[cnt]=pi{y, z}; g[y].push_back(cnt); } g1[x].push_back(y); g1[y].push_back(x); } dij(); //cout << (ans<inf)? ans+1:-1 ; if (ans<inf) cout << ans+1 << endl; else cout << -1; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s015439040
p04003
C++
#include "debug.h" #include <string.h> #include <limits.h> #include <map> #include <set> #include <vector> #include <algorithm> using namespace std; #define MAXN 100000 template<class T> struct gufs { map<T,T> f; map<T,int> c; T find(T v) { T r, u; for(r=v; f.find(r) != f.end(); r=f[r]); for(u=v; u!=r; ) { T t = f[u]; f[u] = r; u = t; } if (c.find(r)==c.end()) c[r] = 1; return r; } T merge(T a, T b) { a = find(a); b = find(b); if (a!=b) { f[a] = b; c[b] += c[a]; } return b; } void clear() { f.clear(); c.clear(); } int count(int v){ return c[find(v)]; } void get_sets(map<T,vector<T>> &s) { for (auto &x: f) { s[find(x.first)].push_back(x.first); } for (auto &x: s) { s[x.first].push_back(x.first); } } }; int n, m; vector<pair<int,int>> g[MAXN]; map<int, gufs<int>> u; map<int, map<int, vector<int>>> us; int q[MAXN]; int h, t; int dist[MAXN]; void adde(int a, int b, int c) { g[a].push_back({b,c}); g[b].push_back({a,c}); u[c].merge(a, b); } int input() { if (scanf("%d %d", &n, &m) < 0) return 0; for (int i=0; i<m; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); a--, b--, c--; adde(a,b,c); } return 1; } void init() { for (int i=0; i<n; i++) dist[i] = INT_MAX; for (auto &x: u) x.second.get_sets(us[x.first]); } void push_q(int v, int c, int d) { int r = u[c].find(v); for (auto &x: us[c][r]) { if (d < dist[x]) { dist[x] = d; q[t++] = x; } } } int solve() { h=0, t=0; dist[0] = 0; q[t++] = 0; while (h<t) { int v = q[h++], d = dist[v]; //printf("-->v=%d d=%d\n", v, d); for(auto &x: g[v]) { int u = x.first, c = x.second; //need to process when dist[u]==d if (dist[u] < d) continue; push_q(u, c, d+1); } } //cout << us << endl; printa(dist,n); return dist[n-1]; } void output(int ans) { printf("%d\n", ans==INT_MAX? -1: ans); } void cleanup() { for (int i=0; i<n; i++) g[i].clear(); u.clear(); us.clear(); } int main() { //int ca; scanf("%d", &ca); while (input()) { init(); output(solve()); cleanup(); //break; } }
a.cc:1:10: fatal error: debug.h: No such file or directory 1 | #include "debug.h" | ^~~~~~~~~ compilation terminated.
s242298879
p04003
C++
/// /** * @Samaritan */ #include<bits/stdc++.h> using namespace std; typedef long long LL; #define pb emplace_back #define fi first #define se second #define PII pair<int, int> #define PLL pair<LL, LL> #define PLI pair<LL, int> LL quick_pow (LL a, LL b, LL mod) { LL ans = 1, base = a; while (b) { if (b & 1) (ans *= base) %= mod; b >>= 1; (base *= base) %= mod; } return ans; } inline int log2(const float &x) { return ((unsigned &) x >> 23 & 255) - 127; } void show(int arr[], int len) { for (int i = 0; i <= len; ++i) { cout << arr[i] << " "; } cout << endl; } struct node { int dist, id; node() { } node(int d, int i) : dist(d), id(i) {} bool operator < (const node& k) const { if (dist == k.dist) return id <= k.id; return dist < k.dist; } }; const int mod = 998244353; const int N = 1e5 + 5; const int logN = 20; const int INF = 0x3f3f3f3f; vector<PII> edge[N]; int dist[N]; set<int> type[N]; //bool vis[N]; void work(int n) { memset(dist, INF, sizeof dist); dist[1] = 0; priority_queue<PII> p; p.push(node(0, 1)); while(!p.empty()) { int now = p.top().second; int val = -p.top().first; p.pop(); if (dist[now] < val) continue; for (const auto& pp : edge[now]) { int to = pp.first; int now_type = pp.second; int now_val = val; if (!type[now].count(now_type)) now_val++; // int to_ca=ca+(!type[now].count(to_com)); if (dist[to] > now_val) { dist[to] = now_val; p.push({-now_val, to}); type[to].clear(); type[to].insert(now_type); } else if(dist[to] == now_val) { type[to].insert(now_type); } } } return; memset(dist, INF, sizeof(dist[0]) * (n + 3)); priority_queue<PII, vector< PII >, greater<> > pq; dist[1] = 0; pq.push({0, 1}); while (!pq.empty()) { int pos = pq.top().second; int now_dist = pq.top().first; pq.pop(); // if (vis[pos]) continue; // vis[pos] = true; if (now_dist > dist[pos]) continue; for (const auto& p : edge[pos]) { int to = p.first; int now_type = p.second; int now_val = dist[pos]; if (!type[pos].count(now_type)) now_val++; if (now_val < dist[to]) { dist[to] = now_val; type[to].clear(); type[to].insert(now_type); pq.push({dist[to], to}); } else if (now_val == dist[to]) { type[to].insert(now_type); } } } } int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i <= n; ++i) edge[i].clear(); int l, r, c; for (int i = 0; i < m; ++i) { scanf("%d %d %d", &l, &r, &c); edge[l].pb(r, c); edge[r].pb(l, c); } work(n); if (dist[n] >= INF) puts("-1"); else printf("%d\n", dist[n]); return 0; }
a.cc: In function 'void work(int)': a.cc:62:11: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(node)' 62 | p.push(node(0, 1)); | ~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:5: /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, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; value_type = 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 'node' to 'const std::priority_queue<std::pair<int, int> >::value_type&' {aka 'const 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, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; value_type = 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 'node' to 'std::priority_queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s974960198
p04003
C++
/// /** * @Samaritan */ #include<bits/stdc++.h> using namespace std; typedef long long LL; #define pb emplace_back #define fi first #define se second #define PII pair<int, int> #define PLL pair<LL, LL> #define PLI pair<LL, int> LL quick_pow (LL a, LL b, LL mod) { LL ans = 1, base = a; while (b) { if (b & 1) (ans *= base) %= mod; b >>= 1; (base *= base) %= mod; } return ans; } inline int log2(const float &x) { return ((unsigned &)x >> 23 & 255) - 127; } void show(int arr[], int len) { for (int i = 0; i <= len; ++i) { cout << arr[i] << " "; } cout << endl; } struct node { int dif, id; node() { } node(int d, int i) : dif(d), id(i) {} bool operator < (const node& k) const { return dif < k.dif; } }; const int mod = 998244353; const int N = 2e5 + 5; const int logN = 20; const int INF = 0x3f3f3f3f; vector<PII> edge[N]; int dist[N]; set<int> type[N]; //bool vis[N]; void work(int n) { priority_queue<PII, vector<PII>, greater<> > pq; memset(dist, INF, sizeof(dist[0]) * (n + 3)); // memset(vis, 0, sizeof(vis[0]) * (n + 3)); type[1].clear(); dist[1] = 0; pq.push({0, 1}); while(!pq.empty()) { int now=pq.top().se,ca=pq.top().fi; pq.pop(); if(dist[now]<ca)continue; for (const auto& p : edge[now]) { { int to=p.first,to_com=p.second; int to_ca=ca+(!type[now].count(to_com)); if(dist[to]>to_ca) { dist[to]=to_ca; pq.push({to_ca,to}); type[to].clear(); type[to].insert(to_com); } else if(dist[to]==to_ca) { type[to].insert(to_com); } } } return; while (!pq.empty()) { int pos = pq.top().second; int now_dist = pq.top().first; pq.pop(); // if (vis[pos]) continue; // vis[pos] = true; if (now_dist > dist[pos]) continue; for (const auto& p : edge[pos]) { int to = p.first; int now_type = p.second; int now_val = dist[pos]; if (!type[pos].count(now_type)) now_val++; if (now_val < dist[to]) { dist[to] = now_val; type[to].clear(); type[to].insert(now_type); pq.push({dist[to], to}); } else if (now_val == dist[to]) { type[to].insert(now_type); } } } } int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i <= n; ++i) edge[i].clear(); int l, r, c; for (int i = 0; i < m; ++i) { scanf("%d %d %d", &l, &r, &c); edge[l].pb(r, c); edge[r].pb(l, c); } work(n); if (dist[n] >= INF) puts("-1"); else printf("%d\n", dist[n]); return 0; }
a.cc: In function 'void work(int)': a.cc:113:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 113 | int main() { | ^~ a.cc:113:9: note: remove parentheses to default-initialize a variable 113 | int main() { | ^~ | -- a.cc:113:9: note: or replace parentheses with braces to value-initialize a variable a.cc:113:12: error: a function-definition is not allowed here before '{' token 113 | int main() { | ^ a.cc:130:2: error: expected '}' at end of input 130 | } | ^ a.cc:56:18: note: to match this '{' 56 | void work(int n) { | ^
s386031017
p04003
C++
using namespace std; int n, m, x, y, c, cnt; int d[500020]; vector<pair<int, int> > a[500020]; map<int, int> g[100020]; deque<int> q; int get(int x, int y) { if (g[x].count(y)) { return g[x][y]; } return g[x][y] = ++cnt; } void add(int x, int y, int z) { a[x].push_back(make_pair(y, z)); a[y].push_back(make_pair(x, z)); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { get(i, 0); } for (int i = 0; i < m; i++) { scanf("%d%d%d", &x, &y, &c); int x0 = get(x, 0), xc = get(x, c); int y0 = get(y, 0), yc = get(y, c); add(xc, yc, 0); add(x0, yc, 1); add(xc, y0, 1); } memset(d, -1, sizeof d); d[1] = 0; q.push_back(1); while (q.size()) { int u = q.back(); q.pop_back(); for (pair<int, int> i: a[u]) { if (d[i.first] == -1 || d[i.first] > d[u] + i.second) { d[i.first] = d[u] + i.second; if (i.second == 1) { q.push_front(i.first); } else { q.push_back(i.first); } } } } printf("%d\n", d[n] >> 1); return 0; }
a.cc:4:1: error: 'vector' does not name a type 4 | vector<pair<int, int> > a[500020]; | ^~~~~~ a.cc:5:1: error: 'map' does not name a type 5 | map<int, int> g[100020]; | ^~~ a.cc:6:1: error: 'deque' does not name a type 6 | deque<int> q; | ^~~~~ a.cc: In function 'int get(int, int)': a.cc:8:13: error: 'g' was not declared in this scope 8 | if (g[x].count(y)) { | ^ a.cc:11:16: error: 'g' was not declared in this scope 11 | return g[x][y] = ++cnt; | ^ a.cc: In function 'void add(int, int, int)': a.cc:14:9: error: 'a' was not declared in this scope 14 | a[x].push_back(make_pair(y, z)); | ^ a.cc:14:24: error: 'make_pair' was not declared in this scope 14 | a[x].push_back(make_pair(y, z)); | ^~~~~~~~~ a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' +++ |+#include <utility> 1 | using namespace std; a.cc: In function 'int main()': a.cc:18:9: error: 'scanf' was not declared in this scope 18 | scanf("%d%d", &n, &m); | ^~~~~ a.cc:30:9: error: 'memset' was not declared in this scope 30 | memset(d, -1, sizeof d); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | using namespace std; a.cc:32:9: error: 'q' was not declared in this scope 32 | q.push_back(1); | ^ a.cc:36:22: error: 'pair' was not declared in this scope 36 | for (pair<int, int> i: a[u]) { | ^~~~ a.cc:36:22: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' a.cc:36:27: error: expected primary-expression before 'int' 36 | for (pair<int, int> i: a[u]) { | ^~~ a.cc:46:9: error: expected primary-expression before '}' token 46 | } | ^ a.cc:45:18: error: expected ';' before '}' token 45 | } | ^ | ; 46 | } | ~ a.cc:46:9: error: expected primary-expression before '}' token 46 | } | ^ a.cc:45:18: error: expected ')' before '}' token 45 | } | ^ | ) 46 | } | ~ a.cc:36:21: note: to match this '(' 36 | for (pair<int, int> i: a[u]) { | ^ a.cc:46:9: error: expected primary-expression before '}' token 46 | } | ^ a.cc:47:9: error: 'printf' was not declared in this scope 47 | printf("%d\n", d[n] >> 1); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | using namespace std;
s653871320
p04003
C++
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; 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; } #define int long long //どう辺をはって、最短経路問題を考えるか void solve() { int n, m; cin >> n >> m; vector<P> pairs; rep(i, n) { pairs.pb(P(i, -1)); //別の点を作る } rep(i, m) { cin >> p[i] >> q[i] >> c[i]; --p[i]; --q[i]; pairs.pb(P(p[i], c[i])); pairs.pb(P(q[i], c[i])); } sort(all(pairs)); pairs.erase(unique(all(pairs)), pairs.end()); int sz = pairs.size(); map<P, int> mp; //逆引き rep(i, sz) { mp[pairs[i]] = i; } vector<vector<P>> g(sz); //駅での乗り換え rep(i, sz) { if(pairs[i].sc == -1) continue; int station = pairs[i].fr; int out = mp[P(station, -1)]; g[i].pb(P(out, 0)); g[out].pb(P(i, 1)); //別に余分に辺を張る分には構わない } //路線間の移動 rep(i, m) { int s = mp[P(p[i], c[i])], t = mp[P(q[i], c[i])]; g[s].pb(P(t, 0)); g[t].pb(P(s, 0)); } int start = mp[P(0, -1)], goal = mp[P(n - 1, -1)]; vector<int> dist(sz, -1); deque<int> deq; deq.push_back(start); dist[start] = 0; while(deq.size()) { int x = deq.front(); deq.pop_front(); for(auto& y: g[x]) { int to = y.fr, cost = y.sc; if(dist[to] == -1) { if(cost == 0) { dist[to] = dist[x]; deq.push_front(to); } else { dist[to] = dist[x] + 1; deq.push_back(to); } } } } cout << dist[goal] << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //init(); solve(); //cout << "finish" << endl; return 0; }
a.cc: In function 'void solve()': a.cc:60:16: error: 'p' was not declared in this scope 60 | cin >> p[i] >> q[i] >> c[i]; | ^ a.cc:60:24: error: 'q' was not declared in this scope 60 | cin >> p[i] >> q[i] >> c[i]; | ^ a.cc:60:32: error: 'c' was not declared in this scope 60 | cin >> p[i] >> q[i] >> c[i]; | ^ a.cc:85:22: error: 'p' was not declared in this scope 85 | int s = mp[P(p[i], c[i])], t = mp[P(q[i], c[i])]; | ^ a.cc:85:28: error: 'c' was not declared in this scope 85 | int s = mp[P(p[i], c[i])], t = mp[P(q[i], c[i])]; | ^ a.cc:86:19: error: 't' was not declared in this scope 86 | g[s].pb(P(t, 0)); | ^
s145233217
p04003
C++
#include <queue> #include <vector> #include <cstdio> #include <iostream> using namespace std; const int N = 1e6; int n, m; int tot = 0, tag = 0, cnt = 0; int vis[N], b[N], fa[N], num[N], Link[N], dis[N]; struct node { int x, y; }; struct edge { int y, next, v; } e[N*2]; vector < node > a[N]; int read(void) { int s = 0, w = 0; char c = getchar(); while (c < '0' || c > '9') w |= c == '-', c = getchar(); while (c >= '0' && c <= '9') s = s*10+c-48, c = getchar(); return w ? -s : s; } int get(int x) { if (fa[x] == x) return x; return fa[x] = get(fa[x]); } void add(int x,int y,int v) { e[++tot] = edge{y,Link[x],v}; Link[x] = tot; } void work(int x) { int t = 0; tag ++; for (int i=0;i<a[x].size();++i) { int p1 = a[x][i].x, p2 = a[x][i].y; if (vis[p1] != tag) b[++t] = p1, vis[p1] = tag; if (vis[p2] != tag) b[++t] = p2, vis[p2] = tag; } for (int i=1;i<=t;++i) fa[b[i]] = b[i]; for (int i=0;i<a[x].size();++i) { int p1 = a[x][i].x, p2 = a[x][i].y; fa[get(p1)] = get(p2); } tag ++; for (int i=1;i<=t;++i) { int r = get(b[i]); if (vis[r] != tag) { vis[r] = tag; num[r] = ++ cnt; } add(b[i],num[r],1); add(num[r],b[i],1); } return; } int Dijkstra(void) { memset(vis,0,sizeof vis); memset(dis,30,sizeof dis); dis[1] = 0; priority_queue < pair<int,int> > q; q.push(make_pair(0,1)); while (q.size()) { int x = q.top().second; q.pop(); if (vis[x]) continue; vis[x] = 1; if (x == n) return dis[x] / 2; for (int i=Link[x];i;i=e[i].next) { int y = e[i].y, v = e[i].v; if (dis[x] + v < dis[y]) { dis[y] = dis[x] + v; q.push(make_pair(-dis[y],y)); } } } return -1; } int main(void) { n = cnt = read(), m = read(); for (int i=1;i<=m;++i) { int x = read(), y = read(), v = read(); a[v].push_back(node{x,y}); } for (int i=1;i<=1e6;++i) if (a[i].size()) work(i); printf("%d", Dijkstra()); return 0; }
a.cc: In function 'int Dijkstra()': a.cc:67:9: error: 'memset' was not declared in this scope 67 | memset(vis,0,sizeof vis); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <iostream> +++ |+#include <cstring> 5 |
s504179906
p04003
C
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} struct edge{ int to, num; }; const int INF = 1001001001; const int MAX_V = 200005; int V,E; vector<edge> G[MAX_V]; int d[MAX_V]; set<int> se[MAX_V]; int f[MAX_V]; void dijkstra(int s){ // greater<P>を指定することでfirstが小さい順に取り出せるようにする priority_queue<P, vector<P>, greater<P> > que; fill(d, d+V, INF); d[s] = 0; que.push(P(0, s)); while(!que.empty()){ P p = que.top(); que.pop(); int v = p.second; if(d[v] >= d[V-1])continue; if(f[v] == 1)continue; f[v] = 1; for(int i=0; i<G[v].size(); i++){ edge e = G[v][i]; if(d[e.to] >= d[v]){ auto it = se[v].find(e.num); if(it != se[v].end()){ if(d[e.to] == d[v]){ auto it2 = se[e.to].find(e.num); if(it2 == se[e.to].end()){ se[e.to].insert(e.num); f[e.to] = 0; que.push(P(d[e.to], e.to)); } }else{ se[e.to].clear(); se[e.to].insert(e.num); d[e.to] = d[v]; f[e.to] = 0; que.push(P(d[e.to], e.to)); } }else if(d[e.to] > d[v]){ if(d[e.to] == d[v] + 1){ auto it2 = se[e.to].find(e.num); if(it2 == se[e.to].end()){ se[e.to].insert(e.num); f[e.to] = 0; que.push(P(d[e.to], e.to)); } }else{ se[e.to].clear(); se[e.to].insert(e.num); d[e.to] = d[v] + 1; f[e.to] = 0; que.push(P(d[e.to], e.to)); } } } } } } int main() { cin >> V >> E; rep(i,E){ int from,to,num; cin >> from >> to >> num; from--; to--; edge e1, e2; e1.to = to; e1.num = num; e2.to = from; e2.num = num; G[from].push_back(e1); G[to].push_back(e2); } dijkstra(0); if(d[V-1] == INF)d[V-1] = -1; cout << d[V-1] << endl; return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s214929980
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=1000000007,MAX=600005,INF=1<<30; vector<pair<int,int>> S[MAX]; vector<int> dis(MAX); void dijkstra(int u){ dis[u]=0; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> PQ; PQ.push(make_pair(0,u)); while(!PQ.empty()){ int a=PQ.top().first; int b=PQ.top().second; PQ.pop(); if(dis[b]<a) continue; for(int i=0;i<S[b].size();i++){ int c=S[b][i].first; int d=S[b][i].second; if(dis[c]>dis[b]+d){ dis[c]=dis[b]+d; PQ.push(make_pair(dis[c],c)); } } } return; }//a,dが長さ int main(){ int N,M;cin>>N>>M; unordered_map <pair<int,int>,int> MA; for(int i=0;i<600005;i++){ dis[i]=INF; } int now=1; for(int i=0;i<M;i++){ int a,b,c,d,e;cin>>a>>b>>c; if(MA[make_pair(a,c)]){ if(MA[make_pair(b,c)]){ d=MA[make_pair(a,c)];e=MA[make_pair(b,c)]; }else{ d=MA[make_pair(a,c)];e=now; MA[make_pair(b,c)]=e; now++; } }else{ if(MA[make_pair(b,c)]){ d=now;e=MA[make_pair(b,c)]; MA[make_pair(a,c)]=d; now++; }else{ d=now;now++; e=now;now++; MA[make_pair(a,c)]=d;MA[make_pair(b,c)]=e; } } S[d].push_back(make_pair(e,0)); S[e].push_back(make_pair(d,0)); S[d].push_back(make_pair(500000+a,0)); S[e].push_back(make_pair(500000+b,0)); S[500000+a].push_back(make_pair(d,1)); S[500000+b].push_back(make_pair(e,1)); } dijkstra(500001); if(dis[500000+N]!=INF) cout<<dis[500000+N]<<endl; else cout<<-1<<endl; }
a.cc: In function 'int main()': a.cc:35:39: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 35 | unordered_map <pair<int,int>,int> MA; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error:
s330742881
p04003
C++
#include <bits/stdc++.h> using namespace std ; const int N = 1e5 +10 ; const int inf = 1 << 30 ; struct st{int p,b,c;}; bool operator < (st a,st b){return a.c>b.c;} inline int read(){ char c;int f=1 ; while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ; int res=c-'0' ; while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ; return res*f ; } map<int ,vector<int> > E[N] ; map<int,int > d[N] ; vector <int> G[N]; priority_queue <st> q ; int n,m; int main(){ n=read();m=read() ; for (int i=1;i<=m;i++){ int a,b,c ; a=read();b=read();c=read();a--;b-- ; E[a][c].push_back(b) ;E[b][c].push_back(a) ; G[a].push_back(c) ;G[b].push_back(c) ; } d[0][0]=0;q.push({0,0,0}) ; while(!q.empty()){ if (d[p.p][p.b]!=p.c){ continue ; } if (d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c){ d[p.p][0]=p.c ; q.push({p.p,0,p.c}) ; } if (p.b==0){ for (int i=0;i<G[p.p].size();i++){ int v=G[p.p][i] ; if (d[p.p].find(v)==d[p.p].end() || d[p.p][v]>p.c+1){ d[p.p][v]=p.c+1 ; q.push({p.p,v,p.c+1}) ; } } continue ; } for (int i=0;i<E[p.p][p.b].size();i++){ int v=E[p.p][p.b][i] ; if (d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){ d[v][p.b]=p.c ; q.push({v,p.b,p.c}) ; } } } int ans=inf ; for (map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) ans=min(ans,p->second) ; if (ans==inf) printf("-1\n") ; else printf("%d\n",ans) ; return 0; }
a.cc: In function 'int main()': a.cc:29:15: error: 'p' was not declared in this scope 29 | if (d[p.p][p.b]!=p.c){ | ^ a.cc:32:15: error: 'p' was not declared in this scope 32 | if (d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c){ | ^ a.cc:34:19: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 34 | q.push({p.p,0,p.c}) ; | ~~~~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:36:13: error: 'p' was not declared in this scope 36 | if (p.b==0){ | ^ a.cc:41:27: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 41 | q.push({p.p,v,p.c+1}) ; | ~~~~~~^~~~~~~~~~~~~~~ /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:46:26: error: 'p' was not declared in this scope 46 | for (int i=0;i<E[p.p][p.b].size();i++){ | ^ a.cc:50:23: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 50 | q.push({v,p.b,p.c}) ; | ~~~~~~^~~~~~~~~~~~~ /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s276999990
p04003
C++
#include <bits/stdc++.h> using namespace std ; const int N = 1e5 +10 ; const int inf = 1 << 30 ; struct st{int p,b,c;}; bool operator < (st a,st b){return a.c>b.c;} inline int read(){ char c;int f=1 ; while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ; int res=c-'0' ; while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ; return res*f ; } map<int ,vector<int> > E[N] ; map<int,int > d[N] ; vector <int> G[N]; priority_queue <st> q ; int n,m; int main(){ n=read();m=read() ; for (int i=1;i<=m;i++){ int a,b,c ; a=read();b=read();c=read();a--;b-- ; E[a][c].push_back(b) ;E[b][c].push_back(a) ; G[a].push_back(c) ;G[b].push_back(c) ; } d[0][0]=0;q.push({0,0,0}) ; while(!q.empty()){ if (d[p.p][p.b]!=p.c){ continue ; } if (d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c){ d[p.p][0]=p.c ; q.push({p.p,0,p.c}) ; } if (p.b==0){ for (int i=0;i<G[p.p].size();i++){ int v=G[p.p][i] ; if (d[p.p].find(v)==d[p.p].end() || d[p.p][v]>p.c+1){ d[p.p][v]=p.c+1 ; q.push({p.p,v,p.c+1}) ; } } continue ; } for (int i=0;i<E[p.p][p.b].size();i++){ int v=E[p.p][p.b][i] ; if (d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){ d[v][p.b]=p.c ; q.push({v,p.b,p.c}) ; } } } int ans=inf ; for (map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) ans=min(ans,p->second) ; if (ans==inf) printf("-1\n") ; else printf("%d\n",ans) ; return 0; }
a.cc: In function 'int main()': a.cc:29:15: error: 'p' was not declared in this scope 29 | if (d[p.p][p.b]!=p.c){ | ^ a.cc:32:15: error: 'p' was not declared in this scope 32 | if (d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c){ | ^ a.cc:34:19: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 34 | q.push({p.p,0,p.c}) ; | ~~~~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:36:13: error: 'p' was not declared in this scope 36 | if (p.b==0){ | ^ a.cc:41:27: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 41 | q.push({p.p,v,p.c+1}) ; | ~~~~~~^~~~~~~~~~~~~~~ /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:46:26: error: 'p' was not declared in this scope 46 | for (int i=0;i<E[p.p][p.b].size();i++){ | ^ a.cc:50:23: error: no matching function for call to 'std::priority_queue<st>::push(<brace-enclosed initializer list>)' 50 | q.push({v,p.b,p.c}) ; | ~~~~~~^~~~~~~~~~~~~ /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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&' {aka 'const st&'} 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 = st; _Sequence = std::vector<st, std::allocator<st> >; _Compare = std::less<st>; value_type = st]' 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<st>::value_type&&' {aka 'st&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s046019770
p04003
C++
#include<bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define lfs <<fixed<<setprecision(10)<< #define test cout<<"test"<<endl; #define fi first #define se second #define MP make_pair #define PB push_back #define EB emplace_back #define rep(i,n,m) for(ll i = n; i < (ll)(m); i++) #define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--) typedef int ll; typedef long double ld; const ll MOD = 1e9+7; //const ll MOD = 998244353; const ll INF = 1e9; using P = pair<ll, ll>; template<typename T> void chmin(T &a,T b){if(a>b)a=b;} template<typename T> void chmax(T &a,T b){if(a<b)a=b;} void pmod(ll &a,ll b){a=(a+b)%MOD;} void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;} void qmod(ll &a,ll b){a=(a*b)%MOD;} void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;} ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});} void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;} void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;} void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;} template<typename T1,typename T2> void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;} template<typename T> void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++) {cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}}; void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++) {for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}}; template<typename T> void debug(vector<T>v,ll n){cout<<v[0]; for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;}; template<typename T> vector<vector<T>>vec(ll x, ll y, T w){ vector<vector<T>>v(x,vector<T>(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} template<typename T> void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;} vector<ll>dx={1,0,-1,0,1,1,-1,-1}; vector<ll>dy={0,1,0,-1,1,-1,1,-1}; struct edge{ ll t,c; }; struct z{ ll v,p;//vertex,price,company }; int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); ll res=0,res1=INF,res2=-INF,buf=0; bool judge = true; ll n,m;cin>>n>>m; vector<vector<edge>>g(n); rep(i,0,m){ ll p,q,c; cin>>p>>q>>c; g[p-1].push_back({q-1,c}); g[q-1].push_back({p-1,c}); } deque<struct z>deq; deq.PB({0,0}); vector<ll>d(n,INF); vector<unordered_set<ll>>st(n); d[0]=0; while(!deq.empty()){ struct z x=deq.front(); deq.pop_front(); rep(i,0,g[x.v].size()){ ll k=x.p+(st[x.v].find(g[x.v][i].c)==st[x.v].end()); //cout<<x.v spa k<<endl; if(k==d[g[x.v][i].t]){ if(st[g[x.v][i].t].find(g[x.v][i].c) ==st[g[x.v][i].t].end()){ st[g[x.v][i].t].insert(g[x.v][i].c); if(k==x.p){ deq.push_front({g[x.v][i].t,k}); } } } else if(k<d[g[x.v][i].t]){ d[g[x.v][i].t]=k; set<ll>tmp; tmp.insert(g[x.v][i].c); st[g[x.v][i].t]=tmp; if(k==x.p){ deq.push_front({g[x.v][i].t,k}); } else deq.push_back({g[x.v][i].t,k}); } } //cout<<x.v spa x.p spa st[x.v].size()<<endl; //debug(d,n); /*rep(j,0,n){ cout<<j+1<<endl; for(auto z:st[j])cout<<z<<" "; cout<<endl; }*/ } ans(d[n-1]==INF,-1,d[n-1]); return 0; }
a.cc: In function 'int main()': a.cc:96:25: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<int> >, std::unordered_set<int> >::value_type' {aka 'std::unordered_set<int>'} and 'std::set<int>') 96 | st[g[x.v][i].t]=tmp; | ^~~ In file included from /usr/include/c++/14/unordered_set:41, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:189, from a.cc:1: /usr/include/c++/14/bits/unordered_set.h:273:7: note: candidate: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>& std::unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(const std::unordered_set<_Value, _Hash, _Pred, _Alloc>&) [with _Value = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<int>]' 273 | operator=(const unordered_set&) = default; | ^~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:273:17: note: no known conversion for argument 1 from 'std::set<int>' to 'const std::unordered_set<int>&' 273 | operator=(const unordered_set&) = default; | ^~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:277:7: note: candidate: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>& std::unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(std::unordered_set<_Value, _Hash, _Pred, _Alloc>&&) [with _Value = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<int>]' 277 | operator=(unordered_set&&) = default; | ^~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:277:17: note: no known conversion for argument 1 from 'std::set<int>' to 'std::unordered_set<int>&&' 277 | operator=(unordered_set&&) = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:291:7: note: candidate: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>& std::unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(std::initializer_list<typename std::_Hashtable<_Value, _Value, _Alloc, std::__detail::_Identity, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Tp&> > >::value, true, true> >::value_type>) [with _Value = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<int>; typename std::_Hashtable<_Value, _Value, _Alloc, std::__detail::_Identity, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Tp&> > >::value, true, true> >::value_type = int]' 291 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:291:46: note: no known conversion for argument 1 from 'std::set<int>' to 'std::initializer_list<int>' 291 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s387170416
p04003
C++
#include <bits/stdc++.h> using namespace std; #define pp pair<int,int> #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define ll long long #define all(a) (a).begin(),(a).end() ll MOD=1000000007; ll mod=998244353; int inf=1000001000; ll INF=10000000000000000; int main(){ int m,n; cin >> n >> m; vector<vector<pp>> e(n+1,vector<pp>(0)); vector< vector<int> d(n+1,inf); d.at(1)=0; rep(i,m){ int p,q,c; cin >> p >> q >> c; e.at(p).push_back(make_pair(q,c)); e.at(q).push_back(make_pair(p,c)); } queue<pp> q; queue<pair<pp,pp>> qq; q.push(make_pair(1,0)); while (!q.empty()){ int u=q.front().first,c=q.front().second; q.pop(); rep(i,e.at(u).size()){ if (d.at(e.at(u).at(i).first)>c+1) { qq.push(make_pair(make_pair(e.at(u).at(i).first,u),make_pair(e.at(u).at(i).second,c+1))); q.push(make_pair(e.at(u).at(i).first,c+1));d.at(e.at(u).at(i).first)=c+1;} } while (!qq.empty()){ int f=qq.front().first.first,g=qq.front().first.second,h=qq.front().second.first,k=qq.front().second.second; qq.pop(); rep(i,e.at(f).size()){ if (e.at(f).at(i).second==h && e.at(f).at(i).first!=g){ if (d.at(e.at(f).at(i).first)>k) {q.push(make_pair(e.at(f).at(i).first,k));d.at(e.at(f).at(i).first)=k;} qq.push(make_pair(make_pair(e.at(f).at(i).first,f),make_pair(e.at(f).at(i).second,k))); } } } } if (d.at(n)==inf) cout << -1 << endl; else cout << d.at(n) << endl; }
a.cc: In function 'int main()': a.cc:18:26: error: template argument 1 is invalid 18 | vector<int> d(n+1,inf); | ^ a.cc:18:26: error: template argument 2 is invalid a.cc:19:5: error: 'd' was not declared in this scope 19 | d.at(1)=0; | ^
s999566331
p04003
C++
#include<bits/stdc++.h> using namespace std; #define int long long #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif const int N = 200001 * 2 + N; struct edge{ int to,cost; }; vector< edge > G[N]; void dikstra(int s,int t){ typedef pair<int, int> P; const int INF = 1 << 30; priority_queue<P,vector<P>,greater<P>> que; vector<int> d(N,INF); //sからの最短距離 d[s] = 0; que.push({0,s}); //{最短距離,頂点} while( !que.empty() ){ P p = que.top(); que.pop(); int v = p.second; if(d[v] < p.first) continue; for(auto e : G[v]){ if(d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push( {d[e.to],e.to} ); } } } if(d[t] == INF) cout << -1 << endl; else cout << d[t] << endl; } using P = pair<int,int>; signed main(){ int n,m; cin >> n >> m; vector<int> p(m),q(m),c(m); vector<vector<int>> station(n); vector<P> v; for(int i = 0; i < m; i++){ cin >> p[i] >> q[i] >> c[i]; p[i]--,q[i]--,c[i]--; station[p[i]].push_back(c[i]); station[q[i]].push_back(c[i]); v.push_back({p[i],c[i]}); v.push_back({q[i],c[i]}); } for(int i = 0; i < n; i++){ v.push_back({i,-1}); } // sort(v.begin(),v.end()); // v.erase(unique(v.begin(),v.end()),v.end()); map<pair<int,int>,int> mp; for(int i = 0; i < v.size(); i++){ mp[v[i]] = i; } for(int i = 0; i < n; i++){ for(int c : station[i]){ int u = mp[{i,c}]; int v = mp[{i,-1}]; G[v].push_back({u,0}); G[u].push_back({v,1}); } } for(int i = 0; i < m; i++){ int u = mp[{p[i],c[i]}]; int v = mp[{q[i],c[i]}]; G[u].push_back({v,0}); G[v].push_back({u,0}); } dikstra(mp[{0,-1}],mp[{n-1,-1}]); return 0; }
a.cc:11:18: error: size of array 'G' is not an integral constant-expression 11 | vector< edge > G[N]; | ^
s691619447
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef pair<int, int> ii; typedef vector<int> vi; #define mkpr make_pair const int N = 1e5 + 5; const int M = 2e5 + 5; int n, m; vector<vector<ii>> edgeList(M); vector<bool> vis(N, false); vector<bool> inStack(N, false); vector<bool> groupVis(M, false); vector<vector<int>> vsGroups(N); vector<vector<int>> groupsVs(M); map<int, int> colorReindexer; //colorReindexer[oldInd] gives newInd int minUnusedIndex; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; minUnusedIndex = 0; int p, q, c; for(int i=0; i<m; i++) { cin >> p >> q >> c; p--; q--; c--; if(colorReindexer.find(c) == colorReindexer.end()) { colorReindexer.insert(mkpr(c, minUnusedIndex++)); } int cIndex = colorReindexer[c]; edgeList[cIndex].push_back(mkpr(p, q)); edgeList[cIndex].push_back(mkpr(q, p)); } //Process by color int nGroup = 0; for(int i = 0; i < minUnusedIndex; i++) { vector<ii> companyProperty; companyProperty.reserve(edgeList[i].size()); for(ii e: edgeList[i]) { companyProperty.push_back(e); vis[e.first] = inStack[e.first] = false; vis[e.second] = inStack[e.second] = false; } sort(companyProperty.begin(), companyProperty.end()); int unusedEdge = 0; stack<int> st; st.push(companyProperty[unusedEdge].first); st.push(companyProperty[unusedEdge].second); inStack[companyProperty[unusedEdge].first] = true; inStack[companyProperty[unusedEdge].second] = true; while(unusedEdge < companyProperty.size()) { while(!st.empty()) { int u = st.top(); st.pop(); if(vis[u]) continue; vis[u] = true; vsGroups[u].push_back(nGroup); groupsVs[nGroup].push_back(u); int starter = lower_bound(companyProperty.begin(), companyProperty.end(), mkpr(u, 0)) - companyProperty.begin(); int ender = upper_bound(starter, companyProperty.end(), mkpr(u, N)) - companyProperty.begin(); for(int i = starter; i != ender; i++) { ii v = companyProperty[i]; if(inStack[v.second]) continue; st.push(v.second); inStack[v.second] = true; } } nGroup++; while(unusedEdge < companyProperty.size() && vis[companyProperty[unusedEdge].first]) unusedEdge++; } } for(int i = 0; i < n; i++) vis[i] = false; for(int i = 0; i < m; i++) groupVis[i] = false; int ans = 0; stack<int> st; stack<int> newSt; st.push(0); bool nReached = false; while(!st.empty() && !nReached) { stack<int> groupStack; while(!st.empty()) { int u = st.top(); st.pop(); for(int g: vsGroups[u]) { if(!groupVis[g]) { groupStack.push(g); groupVis[g] = true; } } } while(!groupStack.empty()) { int g = groupStack.top(); groupStack.pop(); for(int u: groupsVs[g]) { if(!vis[u]) { if(u == n-1) nReached = true; newSt.push(u); vis[u] = true; } } } ans++; while(!newSt.empty()) { st.push(newSt.top()); newSt.pop(); } } cout << (nReached? ans:-1) << endl; return 0; }
a.cc: In function 'int main()': a.cc:72:56: error: no matching function for call to 'upper_bound(int&, std::vector<std::pair<int, int> >::iterator, std::pair<int, int>)' 72 | int ender = upper_bound(starter, companyProperty.end(), mkpr(u, N)) - companyProperty.begin(); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:2019:5: note: candidate: 'template<class _FIter, class _Tp> _FIter std::upper_bound(_FIter, _FIter, const _Tp&)' 2019 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2019:5: note: template argument deduction/substitution failed: a.cc:72:56: note: deduced conflicting types for parameter '_FIter' ('int' and '__gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >') 72 | int ender = upper_bound(starter, companyProperty.end(), mkpr(u, N)) - companyProperty.begin(); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2050:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::upper_bound(_FIter, _FIter, const _Tp&, _Compare)' 2050 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2050:5: note: candidate expects 4 arguments, 3 provided
s378770171
p04003
C++
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define reset(a,b) memset(a,b,sizeof a); #define ALL(x) x.begin(),x.end() #define debug(x) cout<<#x<<" = "<<(x)<<endl #define sz(x) (int)(x.size()) #define lt(x) (int)(x.length()) #define MOD 1000000007 #define mx 1000003 int n, m, p, q, c, dist[mx], idx, kota[mx], company[mx]; set<int> daftar[mx]; vector<pair<int, int>> g[mx]; map<pair<int, int>, int> indeks; int getindeks(int i, int j){ if(indeks.count({i, j})) return indeks[{i, j}]; kota[idx] = i; company[idx] = j; indeks[{i, j}] = idx++; return idx - 1; } int main(){ cin >> n >> m; for(int i = 0; i < m; i++){ cin >> p >> q >> c; p -= 1, q -= 1, c -= 1; g[p].pb({c, q}); g[q].pb({c, q}); daftar[p].insert(c); daftar[q].insert(c); } for(int i = 0; i < n; i++) sort(ALL(g[i])); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; reset(dist, -1); pq.push({0, getindeks(0, -1)}); dist[getindeks(0, -1)] = 0; while(!pq.empty()){ int now, dis; tie(dis, now) = pq.top(); pq.pop(); // debug(kota[now]); // debug(company[now]); // debug(dis); if(company[now] == -1){ for(int i : daftar[kota[now]]){ if(dist[getindeks(kota[now], i)] == -1 || dist[getindeks(kota[now], i)] > dis + 1){ dist[getindeks(kota[now], i)] = dis + 1; pq.push({dis + 1, getindeks(kota[now], i)}); } } continue; } // int it1, it2; int it1 = lower_bound(ALL(g[kota[now]]), make_pair(company[now], -1), [&](pair<int, int> x, pair<int, int> y){ return x.f < y.f; }) - g[kota[now]].begin(); int it2 = upper_bound(ALL(g[kota[now]]), make_pair(company[now], 1e9), [&](pair<int, int> x, pair<int, int> y){ return x.f < y.f; }) - g[kota[now]].begin(); for(int x = it1; x < it2; x++){ auto i = g[kota[now]][x]; assert(company[now] == i.f) int cost = 0; if(dist[getindeks(i.s, i.f)] == -1 || dist[getindeks(i.s, i.f)] > dis + cost){ dist[getindeks(i.s, i.f)] = dis + cost; pq.push({dis + cost, getindeks(i.s, i.f)}); } } if(dist[getindeks(kota[now], -1)] == -1 || dist[getindeks(kota[now], -1)] > dis){ dist[getindeks(kota[now], -1)] = dis; pq.push({dis, getindeks(kota[now], -1)}); } } int jaw = dist[getindeks(n - 1, -1)]; // for(int i : daftar[n - 1]){ // if(dist[getindeks(n - 1, i)] == -1) // continue; // jaw = min(jaw, dist[getindeks(n - 1, i)]); // } if(jaw == 1e9) jaw = -1; cout << jaw << endl; }
a.cc: In function 'int main()': a.cc:71:25: error: expected ';' before 'int' 71 | int cost = 0; | ^~~ a.cc:72:97: error: 'cost' was not declared in this scope; did you mean 'cosl'? 72 | if(dist[getindeks(i.s, i.f)] == -1 || dist[getindeks(i.s, i.f)] > dis + cost){ | ^~~~ | cosl a.cc:74:40: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(<brace-enclosed initializer list>)' 74 | pq.push({dis + cost, getindeks(i.s, i.f)}); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /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, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; value_type = 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, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&' {aka 'const 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, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; value_type = 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, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, int>&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s400993560
p04003
C++
#include<bits/stdc++.h> //ios::sync_with_stdio(false); //cin.tie(0); using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<pii,int> ppii; typedef pair<int,pii> pipi; typedef pair<ll,ll> pll; typedef pair<pll,ll> ppll; typedef pair<ll,pll> plpl; typedef tuple<ll,ll,ll> tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; double pi=2*acos(0); #define rep(i,m,n) for(int i=m;i<n;i++) #define rrep(i,n,m) for(int i=n;i>=m;i--) int dh[4]={1,-1,0,0}; int dw[4]={0,0,1,-1}; int ddh[8]={-1,-1,-1,0,0,1,1,1}; int ddw[8]={-1,0,1,-1,1,-1,0,1}; ll lmax(ll a,ll b){ if(a<b)return b; else return a; } ll lmin(ll a,ll b){ if(a<b)return a; else return b; } int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n,m;cin>>n>>m; vector<pll> v[n+1]; vector<ll> col[n+1]; rep(i,0,m){ ll p,q,c;cin>>p>>q>>c; v[p].push_back({q,c}); v[q].push_back(make_pair(p,c)); col[p].push_back(c); col[q].push_back(c); } unordered_map<pll,ll> mp; rep(i,1,n+1){ rep(j,0,col[i].size()){ if(i==1)mp[{1,col[i][j]}]=0; else mp[{i,col[i][j]}]=inf; } } ll d[n+1]; fill(d,d+n+1,inf); priority_queue<plpl,vector<plpl>,greater<plpl>> q; q.push({0,{1,-1}}); d[1]=0; while(q.size()>0){ plpl p=q.top(); q.pop(); ll now=p.second.first; ll dis=p.first; d[now]=min(d[now],dis); ll par=p.second.second; rep(i,0,v[now].size()){ ll ne=v[now][i].first; ll co=v[now][i].second; if(par!=co){ if(mp[{ne,co}]>dis+1){ mp[{ne,co}]=dis+1; q.push({dis+1,{ne,co}}); } } else{ if(mp[{ne,co}]>dis)){ mp[{ne,co}]=dis; q.push({dis,{ne,co}}); } } } } if(d[n]==inf)cout<<-1<<endl; else cout<<d[n]<<endl; }
a.cc: In function 'int main()': a.cc:44:25: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >]' 44 | unordered_map<pll,ll> mp; | ^~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long long int, long long int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<long long int, long long int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, long long int>, std::__detail::_Select1st, std::hash<s
s457411023
p04003
C++
/*************************初中生代码=********************************************************************************/ #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <string> #include <vector> #define pa pair<int, int> using namespace std; const int MAXN = 1000010; int dis[MAXN]; vector<pa> g[MAXN]; vector<int> new_g[MAXN], all[MAXN]; int visit[MAXN], ptr[MAXN]; queue<int> q; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int u, v, c; scanf("%d%d%d", &u, &v, &c); u--, v--; g[u].push_back(make_pair(c, v)); g[v].push_back(make_pair(c, u)); all[c].push_back(u); all[c].push_back(v); } for (int i = 0; i < n; i++) { sort(g[i].begin(), g[i].end()); visit[i] = -1; } int newn = n; for (int i = 0; i < MAXN; i++) { if (all[i].empty()) { continue; } for (int it = 0; it < all[i].size(); it++) { int v = all[i][it]; if (visit[v] == i) { continue; } q.push(v); visit[v] = i; while (!q.empty()) { int x = q.front(); q.pop(); while (ptr[x] < (int)g[x].size()) { int c = g[x][ptr[x]].first; if (c != i) { break; } int u = g[x][ptr[x]].second; if (visit[u] != i) { visit[u] = i; q.push(u); } ptr[x]++; } new_g[x].push_back(newn); new_g[newn].push_back(x); } newn++; } } for (int i = 0; i < newn; i++) { dis[i] = -2; } q.push(0); dis[0] = 0; while (!q.empty()) { int x = q.front(); q.pop(); for (int i = 0; i < new_g[x].size(); i++) { int u = new_g[x][i]; if (dis[u] == -2) { dis[u] = dis[x] + 1; q.push(u); } } } cout << dis[n - 1] / 2; return 0; } /*************************网上代码********************************************************************************/ #include<set> #include<map> #include<stack> #include<cstdio> #include<queue> #include<cmath> #include<vector> #include<climits> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define INF 0x3f3f3f3f #define LL long long int read(){ int f=1,x=0; char c=getchar(); while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} return f*x; } #define MAXN 2200000 struct edge{ int v,w; edge(){} edge(int V,int W){v=V,w=W;} }; int n,m; struct node{ int u,k; node(){} node(int U,int K){u=U,k=K;} friend bool operator < (node a,node b){return a.u==b.u?a.k<b.k:a.u<b.u;} }; struct node1{ int u,v,k; node1(){} node1(int U,int V,int K){u=U,v=V,k=K;} }; vector<node> Make_zx; vector<node1> Make_xx; vector<edge> G[MAXN+5]; int dis[MAXN+5]; bool vis[MAXN+5]; queue<int>Q; int SPFA(int S,int T){ memset(vis,0,sizeof(vis)); memset(dis,0x3f,sizeof(dis)); dis[S]=0,vis[S]=1,Q.push(S); while(!Q.empty()){ int u=Q.front(),v,w,siz=G[u].size(); Q.pop(); vis[u]=0; for(int i=0;i<siz;i++){ v=G[u][i].v,w=G[u][i].w; if(dis[v]>dis[u]+w){ dis[v]=dis[u]+w; if(!vis[v]){ vis[v]=1; Q.push(v); } } } } return dis[T]==INF?-1:dis[T]/2; } int main(){ n=read(),m=read(); for(int i=1;i<=m;i++){ int p=read()-1,q=read()-1,c=read()-1; Make_zx.push_back(node(p,c)); Make_zx.push_back(node(q,c)); Make_xx.push_back(node1(p,q,c)); Make_xx.push_back(node1(q,p,c)); } sort(Make_zx.begin(),Make_zx.end()); for(int i=0;i<int(Make_zx.size());i++){ G[n+i].push_back(edge(Make_zx[i].u,1)); G[Make_zx[i].u].push_back(edge(n+i,1)); } for(int i=0;i<int(Make_xx.size());i++){ int l1=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].u,Make_xx[i].k))-Make_zx.begin(), l2=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].v,Make_xx[i].k))-Make_zx.begin(); G[l1+n].push_back(edge(l2+n,0)); } printf("%d\n",SPFA(0,n-1)); return 0; } /*************************兔子代码********************************************************************************/ #include<iostream> #include<queue> #include<string> #include<cstring> using namespace std; const int N=3e5+100,M=6e5+100; int head[N],ver[M],edge[M],Next[M],d[N]; bool v[N]; int n,m,tot; priority_queue<pair<int,int>>q; void add(int x,int y,int z) { ver[++tot]=y; edge[tot]=z; Next[tot]=head[x]; head[x]=tot; } void dijkstra() { int f=0; memset(d,0x3f3f3f3f,sizeof(d)); memset(v,0,sizeof(v)); d[1]=0; q.push(make_pair(0,1)); while(q.size()) { //int f=0; int x=q.top().second; q.pop(); if(v[x]) continue; v[x]=1; for(int i=head[x];i;i=Next[i]) { int y=ver[i],z; if(f!=edge[i]||f==0) { z=1; f=edge[i]; } else z=0; if(d[y]>d[x]+z) { d[y]=d[x]+z; q.push(make_pair(-d[y],y)); } } } } int main() { cin>>n>>m; memset(head,0,sizeof(head)); for(int i=1;i<=m;i++) { int x,y,z; cin>>x>>y>>z; add(x,y,z); add(y,x,z); } dijkstra(); if(d[n]==(0x3f3f3f3f)) cout<<-1<<endl; else cout<<d[n]<<endl; return 0; }
a.cc:151:5: error: conflicting declaration 'int dis [2200005]' 151 | int dis[MAXN+5]; | ^~~ a.cc:18:5: note: previous declaration as 'int dis [1000010]' 18 | int dis[MAXN]; | ^~~ a.cc:175:5: error: redefinition of 'int main()' 175 | int main(){ | ^~~~ a.cc:23:5: note: 'int main()' previously defined here 23 | int main() | ^~~~ a.cc:209:5: error: redefinition of 'int n' 209 | int n,m,tot; | ^ a.cc:136:5: note: 'int n' previously declared here 136 | int n,m; | ^ a.cc:209:7: error: redefinition of 'int m' 209 | int n,m,tot; | ^ a.cc:136:7: note: 'int m' previously declared here 136 | int n,m; | ^ a.cc:210:30: error: conflicting declaration 'std::priority_queue<std::pair<int, int> > q' 210 | priority_queue<pair<int,int>>q; | ^ a.cc:22:12: note: previous declaration as 'std::queue<int> q' 22 | queue<int> q; | ^ a.cc: In function 'void dijkstra()': a.cc:224:11: error: no matching function for call to 'std::queue<int>::push(std::pair<int, int>)' 224 | q.push(make_pair(0,1)); | ~~~~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from a.cc:10: /usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 283 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::queue<int>::value_type&' {aka 'const int&'} 283 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 288 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'std::queue<int>::value_type&&' {aka 'int&&'} 288 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:228:17: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'? 228 | int x=q.top().second; | ^~~ | pop a.cc:244:23: error: no matching function for call to 'std::queue<int>::push(std::pair<int, int>)' 244 | q.push(make_pair(-d[y],y)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 283 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::queue<int>::value_type&' {aka 'const int&'} 283 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 288 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'std::queue<int>::value_type&&' {aka 'int&&'} 288 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc: At global scope: a.cc:249:5: error: redefinition of 'int main()' 249 | int main() | ^~~~ a.cc:23:5: note: 'int main()' previously defined here 23 | int main() | ^~~~
s778612498
p04003
C++
//#pragma GCC optimize("Ofast") #include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include <fstream> #include <time.h> #define REP(i, n) for(int i = 0;i < n;++i) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;++i) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); //#define int long long #define all(x) (x).begin(), (x).end() using namespace std; int MAX = 100010; int MOD = (ll)1000000000 + 7; ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pair<ll, int>P;//firstは距離、secondは頂点番号 struct Ver { ll dist; set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる struct edge { int to, cmp; };//辺には行き先の頂点と会社を持たせる Ver d[100010]; int V;//頂点数 int M;//辺の本数 vector<edge>G[100010];//グラフ //int d[MAX];//始点からの距離 void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; set<int>st;//キューに入っている頂点番号 //全点への距離をINFで初期化 for (int i = 0; i < V + 1; i++) { d[i].dist = INF; } //始点への距離は0 d[s].dist = 0; //始点をキューに入れる que.push(P(0, s)); st.insert(s); while (!que.empty()) { P p = que.top(); que.pop(); auto c = st.erase(p.second); int v = p.second;//今見ている頂点 if (d[v].dist < p.first)continue; //今見ている頂点につながるすべての辺について距離を更新する for (int i = 0, int n=G[v].size(); i < n; i++) { edge e = G[v][i]; int cost = 1; //vに訪れるのに最後に使った会社(複数の場合もある)が今見ている辺の会社と同じならコストを0にする if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; //今見ている辺を使うことでe.toへの距離が小さくなるなら、距離を更新し、最後に使った会社をe.cmpとする if (d[e.to].dist > d[v].dist + cost) { d[e.to] = { d[v].dist + cost,{ e.cmp } }; que.push(P(d[e.to].dist, e.to)); st.insert(e.to); } //今見ている辺を使っても距離が変わらない場合、最後に使った会社に(もしe.cmpがなかったら)e.cmpを追加する else if (d[e.to].dist == d[v].dist + cost) { if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { d[e.to].company.insert(e.cmp); if (st.find(e.to) == st.end()) { que.push(P(d[e.to].dist, e.to)); st.insert(e.to); } } } } } } int main() { cin >> V >> M; int p, q, c; for (int i = 0; i < M; i++) { scanf("%d %d %d", &p, &q, &c); G[p].push_back({ q,c }); G[q].push_back({ p,c }); } dijkstra(1); ll ans = d[V].dist; if (ans == INF) { cout << -1 << endl; return 0; } cout << ans << endl; }
a.cc: In function 'void dijkstra(int)': a.cc:76:33: error: expected unqualified-id before 'int' 76 | for (int i = 0, int n=G[v].size(); i < n; i++) { | ^~~ a.cc:76:32: error: expected ';' before 'int' 76 | for (int i = 0, int n=G[v].size(); i < n; i++) { | ^~~~ | ; a.cc:76:57: error: expected ')' before ';' token 76 | for (int i = 0, int n=G[v].size(); i < n; i++) { | ~ ^ | ) a.cc:76:59: error: 'i' was not declared in this scope 76 | for (int i = 0, int n=G[v].size(); i < n; i++) { | ^
s778192413
p04003
C++
#include<bits/stdc++.h> #define N 500005 #define M 500005 using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar(); return ans; } int n,m,first[N],cnt=0,d[N]; bool vis[N]; struct edge{int v,next,c;}e[M<<1]; inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;} struct heap{int u,v;}; inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;} priority_queue<heap>q; set<int>col[N]; inline void dijkstra(){ for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false; d[1]=0; q.push((heap){1,d[1]}); while(!q.empty()){ heap x=q.top(); q.pop(); if(vis[x.u])continue; vis[x.u]=1; for(int i=first[x.u];i;i=e[i].next){ int v=e[i].v,w=col[x.u].count(e[i].c)?0:1; if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c); else if(d[v]==d[x.u]+w)col[v].insert(e[i].c); } } } signed main(){ n=read();m=read(); for(int i=1;i<=m;i++){ int x=read();int y=read();int z=read(); addedge(x,y,z);addedge(y,x,z); } memset(dis,0x3f,sizeof(dis)); dijkstra(); if(d[n]==0x3f3f3f3f)cout<<-1<<endl; else cout<<d[n]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:40:9: error: 'addedge' was not declared in this scope; did you mean 'edge'? 40 | addedge(x,y,z);addedge(y,x,z); | ^~~~~~~ | edge a.cc:42:12: error: 'dis' was not declared in this scope; did you mean 'vis'? 42 | memset(dis,0x3f,sizeof(dis)); | ^~~ | vis
s327777228
p04003
C++
#include<bits/stdc++.h> #define N 500005 #define M 500005 using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar(); return ans; } int n,m,first[N],cnt=0,d[N]; bool vis[N]; struct edge{int v,next,c;}e[M<<1]; inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;} struct heap{int u,v;}; inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;} priority_queue<heap>q; set<int>col[N]; inline void dijkstra(){ for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false; q.push((heap){1,d[1]}); while(!q.empty()){ heap x=q.top(); q.pop(); if(vis[x.u])continue; vis[x.u]=1; for(int i=first[x.u];i;i=e[i].next){ int v=e[i].v,w=col[x.u].count(e[i].c)?0:1; if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c); else if(d[v]==d[x.u]+w)col[v].insert(e[i].c); } } } signed main(){ n=read();m=read(); for(int i=1;i<=m;i++){ int x=read();int y=read();int z=read(); addedge(x,y,z);addedge(y,x,z); } memset(dis,0x3f,sizeof(dis)); dijkstra(); if(d[n]==0x3f3f3f3f)cout<<-1<<endl; else cout<<d[n]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:39:9: error: 'addedge' was not declared in this scope; did you mean 'edge'? 39 | addedge(x,y,z);addedge(y,x,z); | ^~~~~~~ | edge a.cc:41:12: error: 'dis' was not declared in this scope; did you mean 'vis'? 41 | memset(dis,0x3f,sizeof(dis)); | ^~~ | vis
s199363106
p04003
C++
#include<bits/stdc++.h> #include<set> #include<queue> #define INF 0x3f3f3f3f using namespace std; inline int read(){ int w=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ w=(w<<3)+(w<<1)+ch-48; ch=getchar(); } return w*f; } int n,m,dis[500010],cnt,head[500010]; set<int> c[500010]; struct Edge{ int from,to,next,col; }edge[5000010]; inline void addedge(int u,int v,int w){ cnt++; edge[cnt].from=u; edge[cnt].to=v; edge[cnt].col=w; edge[cnt].next=head[u]; head[u]=cnt; } struct Node{ int u,dis; }; inline bool operation < (Node x,Node y){ return x.dis<y.dis; } priority_queue<Node> pq; bool vis[500010]; /*inline void dij(int from){ dis[1]=0;pq.push((Node){1,0}); while(!pq.empty()){ Node cur=pq.top();pq.pop();int u=cur.u;if(vis[u])continue;vis[u]=true; for(int i=head[u];i;i=edge[i].next){ int v=edge[i].to;int color=edge[i].col; int w=c[u].count(edge[i].col)?0:1; if(dis[v]>dis[u]+w){ dis[v]=dis[u]+w;c[v].clear();c[v].insert(edge[i].col);pq.push((Node){v,dis[v]}); } else if(dis[v]==dis[u]+w){ c[v].insert(edge[i].col); } } } }*/ inline void dij(){ for(int i=2;i<=n;++i)dis[i]=0x3f3f3f3f,vis[i]=false; dis[1]=0;pq.push((Node){1,dis[1]}); while(!pq.empty()){ Node x=pq.top(); pq.pop(); if(vis[x.u])continue; vis[x.u]=1;int u=x.u; for(int i=head[x.u];i;i=edge[i].next){ int v=edge[i].to,w=c[x.u].count(edge[i].col)?0:1; if(dis[v]>dis[x.u]+w){dis[v]=dis[x.u]+w,pq.push((Node){v,dis[v]}),c[v].clear(),c[v].insert(edge[i].col);} else if(dis[v]==dis[x.u]+w){c[v].insert(edge[i].col);} } } } signed main(){ n=read();m=read(); for(int i=1;i<=m;i++){ int x=read();int y=read();int z=read(); addedge(x,y,z);addedge(y,x,z); } memset(dis,0x3f,sizeof(dis)); dij(); if(dis[n]==INF)cout<<-1<<endl; else cout<<dis[n]<<endl; return 0; }
a.cc:35:23: error: expected initializer before '<' token 35 | inline bool operation < (Node x,Node y){ | ^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]': /usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<Node*, std::vector<Node, std::allocator<Node> > >; _Value = Node; _Compare = std::less<Node>]' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /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<Node*, vector<Node, allocator<Node> > >; _Distance = long int; _Tp = Node; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<Node> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<Node*, vector<Node, allocator<Node> > >; _Compare = less<Node>]' 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = Node; _Sequence = std::vector<Node, std::allocator<Node> >; _Compare = std::less<Node>; value_type = Node]' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:58:21: required from here 58 | dis[1]=0;pq.push((Node){1,dis[1]}); | ~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const Node' and 'const Node') 405 | { return __x < __y; } | ~~~~^~~~~ 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:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::pair<_T1, _T2>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s285910942
p04003
C++
#include<bits/stdc++.h> #include<set> #include<queue> #define INF 0x3f3f3f3f using namespace std; inline int read(){ int w=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ w=(w<<3)+(w<<1)+ch-48; ch=getchar(); } return w*f; } int n,m,dis[500010],cnt,head[500010]; set<int> c[500010]; struct Edge{ int from,to,next,col; }edge[5000010]; inline void addedge(int u,int v,int w){ cnt++; edge[cnt].from=u; edge[cnt].to=v; edge[cnt].col=w; edge[cnt].next=head[u]; head[u]=cnt; } struct Node{ int u,dis; }; inline bool operation > (Node x,Node y){ return x.dis<y.dis; } priority_queue<Node> pq; bool vis[500010]; /*inline void dij(int from){ dis[1]=0;pq.push((Node){1,0}); while(!pq.empty()){ Node cur=pq.top();pq.pop();int u=cur.u;if(vis[u])continue;vis[u]=true; for(int i=head[u];i;i=edge[i].next){ int v=edge[i].to;int color=edge[i].col; int w=c[u].count(edge[i].col)?0:1; if(dis[v]>dis[u]+w){ dis[v]=dis[u]+w;c[v].clear();c[v].insert(edge[i].col);pq.push((Node){v,dis[v]}); } else if(dis[v]==dis[u]+w){ c[v].insert(edge[i].col); } } } }*/ inline void dij(){ for(int i=2;i<=n;++i)dis[i]=0x3f3f3f3f,vis[i]=false; dis[1]=0;pq.push((Node){1,dis[1]}); while(!pq.empty()){ Node x=pq.top(); pq.pop(); if(vis[x.u])continue; vis[x.u]=1;int u=x.u; for(int i=head[x.u];i;i=edge[i].next){ int v=edge[i].to,w=c[x.u].count(edge[i].col)?0:1; if(dis[v]>dis[x.u]+w){dis[v]=dis[x.u]+w,pq.push((Node){v,dis[v]}),c[v].clear(),c[v].insert(edge[i].col);} else if(dis[v]==dis[x.u]+w){c[v].insert(edge[i].col);} } } } signed main(){ n=read();m=read(); for(int i=1;i<=m;i++){ int x=read();int y=read();int z=read(); addedge(x,y,z);addedge(y,x,z); } memset(dis,0x3f,sizeof(dis)); dij(); if(dis[n]==INF)cout<<-1<<endl; else cout<<dis[n]<<endl; return 0; }
a.cc:35:23: error: expected initializer before '>' token 35 | inline bool operation > (Node x,Node y){ | ^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]': /usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<Node*, std::vector<Node, std::allocator<Node> > >; _Value = Node; _Compare = std::less<Node>]' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /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<Node*, vector<Node, allocator<Node> > >; _Distance = long int; _Tp = Node; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<Node> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<Node*, vector<Node, allocator<Node> > >; _Compare = less<Node>]' 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = Node; _Sequence = std::vector<Node, std::allocator<Node> >; _Compare = std::less<Node>; value_type = Node]' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:58:21: required from here 58 | dis[1]=0;pq.push((Node){1,dis[1]}); | ~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const Node' and 'const Node') 405 | { return __x < __y; } | ~~~~^~~~~ 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:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::pair<_T1, _T2>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s564533216
p04003
C++
#include <vector> #include <iostream> #include <cmath> #include <map> #include <algorithm> #include <fstream> #include <unistd.h> #include <string> #include <numeric> #include <queue> #include <deque> #include <sstream> #include <iomanip> #include <set> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<string> vs; typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef pair<int, int> P; typedef pair<ll, ll> PL; typedef vector<P> vp; typedef vector<PL> vpl; typedef vector<vector<P>> vvp; typedef vector<vector<PL>> vvpl; const int INF = 1001001001; const ll LINF = 1e18; const double pi = 3.1415926535897932; const string endstr = "\n"; #define FOR(i, a, b) for(ll i = (a); i < b; i++) #define REP(i, n) for(ll i = 0; i < n; i++) #define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++) #define ff first #define ss second #define pb push_back template <typename T> T gcd(T a, T b) { return (a == 0) ? b : gcd(b%a, a); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;}; bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;}; bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;}; bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;}; template <typename T> vector<T> uniquen(vector<T> vec){ vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } struct edge {ll to, company;}; int main(){ ll N, M; cin >> N >> M; vector<edge> ed[N]; REP(i, M){ ll p, q, c; cin >> p >> q >> c; p--; q--; ed[p].pb({q, c}); ed[q].pb({p, c}); } vl dist(N, LINF); dist[0] = 1; priority_queue<pair<ll, PL>> pq; for(auto e : ed[0]){ pq.push({-1, {0, e.company}}); // -cost, current_vertex, company } while(!pq.empty()){ auto tmp = pq.top(); pq.pop(); ll cur_cost = -tmp.ff; ll cur_ver = tmp.ss.ff; ll cur_company = tmp.ss.ss; if(dist[cur_ver] =< cur_cost) continue; for(auto& e : ed[cur_ver]){ if(e.company == cur_company){ if(dist[e.to] >= dist[cur_ver]){ dist[e.to] = cur_cost; pq.push({-dist[e.to], {e.to, e.company}}); } } else{ if(dist[e.to] >= cur_cost + 1){ dist[e.to] = cur_cost+1; pq.push({-dist[e.to], {e.to, e.company}}); } } } } cout << (dist[N-1] == LINF ? -1 : dist[N-1]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:84:27: error: expected primary-expression before '<' token 84 | if(dist[cur_ver] =< cur_cost) continue; | ^
s768548257
p04003
C++
#include <vector> #include <iostream> #include <cmath> #include <map> #include <algorithm> #include <fstream> #include <unistd.h> #include <string> #include <numeric> #include <queue> #include <deque> #include <sstream> #include <iomanip> #include <set> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<string> vs; typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef pair<int, int> P; typedef pair<ll, ll> PL; typedef vector<P> vp; typedef vector<PL> vpl; typedef vector<vector<P>> vvp; typedef vector<vector<PL>> vvpl; const int INF = 1001001001; const ll LINF = 1e18; const double pi = 3.1415926535897932; const string endstr = "\n"; #define FOR(i, a, b) for(ll i = (a); i < b; i++) #define REP(i, n) for(ll i = 0; i < n; i++) #define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++) #define ff first #define ss second #define pb push_back template <typename T> T gcd(T a, T b) { return (a == 0) ? b : gcd(b%a, a); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;}; bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;}; bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;}; bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;}; template <typename T> vector<T> uniquen(vector<T> vec){ vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } struct edge {ll to, company;}; int main(){ ll N, M; cin >> N >> M; vector<edge> ed[N]; REP(i, M){ ll p, q, c; cin >> p >> q >> c; p--; q--; ed[p].pb({q, c}); ed[q].pb({p, c}); } vl dist(N, LINF); dist[0] = 1; priority_queue<pair<ll, PL>> pq; for(auto e : ed[0]){ pq.push({-1, {0, e.company}}); } bool visit(N, false); while(!pq.empty()){ auto tmp = pq.top(); pq.pop(); ll cur_cost = -tmp.ff; ll cur_ver = tmp.ss.ff; ll cur_company = tmp.ss.ss; if(visit[cur_ver]) continue; visit[cur_ver] = true; for(auto e : ed[cur_ver]){ if(e.company == cur_company){ if(dist[e.to] > dist[cur_ver]){ dist[e.to] = cur_cost; pq.push({-dist[e.to], {e.to, e.company}}); } } else{ if(dist[e.to] > dist[cur_ver] + 1){ dist[e.to] = cur_cost+1; pq.push({-dist[e.to], {e.to, e.company}}); } } } } cout << (dist[N-1] == LINF ? -1 : dist[N-1]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:80:24: error: expression list treated as compound expression in initializer [-fpermissive] 80 | bool visit(N, false); | ^ a.cc:84:17: error: invalid types 'bool[ll {aka long long int}]' for array subscript 84 | if(visit[cur_ver]) continue; | ^ a.cc:85:14: error: invalid types 'bool[ll {aka long long int}]' for array subscript 85 | visit[cur_ver] = true; | ^
s690462637
p04003
C++
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; const int inf = 1e+7; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second typedef long long int; void Yes() { cout<<"Yes"<<endl; exit(0); } void No(){ cout<<"No"<<endl; exit(0); } struct edge {int to, company;}; int N, M; vector<edge> G[100100]; int d[100100]; int zero_one_bfs() { deque<P> deq; rep(i, N) d[i] = inf; d[0] = 0; deq.push_back(P(0, 0)); while(deq.size()) { P p = deq.front(); deq.pop_front(); if(p.fr == N - 1) break; rep(i, G[p.fr].size()) { edge eg = G[p.fr][i]; if(p.sc == eg.company ) { if(d[eg.to] != inf) continue; deq.push_front(P(eg.to, eg.company)); d[eg.to] = d[p.fr]; } else { if(d[eg.to] != inf) continue; deq.push_back(P(eg.to, eg.company)); d[eg.to] = d[p.fr] + 1; } } } if(d[N - 1] == inf) { return -1; } return d[N - 1]; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; rep(i, M) { int p, q, c; cin >> p >> q >> c; p --; q --; G[p].push_back(edge{q, c}); G[q].push_back(edge{p, c}); } int res = zero_one_bfs(); cout << res << "\n"; return 0; }
a.cc:42:19: error: declaration does not declare anything [-fpermissive] 42 | typedef long long int; | ^~~
s622466930
p04003
C++
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; cin>>N>>M; struct Line { int t,c; }; vector<Line> graph[N]; for (int i = 0; i < M; i++) { int p,q,c; cin>>p>>q>>c; p--,q--; graph[p].push_back({q,c}); graph[q].push_back({p,c}); } struct Data { int s,c,v; bool operator<(Data x) {return v < x.v;} }; priority_queue<Data, vector<Data>, greater<Data>> qs; qs.push({0,0,0}); vector<bool> visited(N, false); std::vector<int> costs(N, -1); while (not qs.empty()) { auto& q = qs.top(); qs.pop(); if (costs[q.s] != -1 and q.v >= costs[q.s]) continue; costs[q.s] = q.v; for (auto& line : graph[q.s]) { qs.push({line.t, line.c, q.v + (line.c != q.c ? 1 : 0)}); } } cout << costs.back() << endl; return 0; }
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, from a.cc:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = main()::Data]': /usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<main()::Data*, std::vector<main()::Data> >; _Value = main()::Data; _Compare = std::greater<main()::Data>]' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /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<main()::Data*, vector<main()::Data> >; _Distance = long int; _Tp = main()::Data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<main()::Data> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<main()::Data*, vector<main()::Data> >; _Compare = greater<main()::Data>]' 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = main()::Data; _Sequence = std::vector<main()::Data>; _Compare = std::greater<main()::Data>; value_type = main()::Data]' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:25:12: required from here 25 | qs.push({0,0,0}); | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:395:20: error: no match for 'operator>' (operand types are 'const main()::Data' and 'const main()::Data') 395 | { return __x > __y; } | ~~~~^~~~~ 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:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:395:20: note: 'const main()::Data' is not derived from 'const std::pair<_T1, _T2>' 395 | { return __x > __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:395:20: note: 'const main()::Data' is not derived from 'const std::reverse_iterator<_Iterator>' 395 | { return __x > __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:395:20: note: 'const main()::Data' is not derived from 'const std::reverse_iterator<_Iterator>' 395 | { return __x > __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:395:20: note: 'const main()::Data' is not derived from 'const std::move_iterator<_IteratorL>' 395 | { return __x > __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:395:20: note: 'const main()::Data' is not derived from 'const std::move_iterator<_IteratorL>' 395 | { return __x > __y; } | ~~~~^~~~~
s913715016
p04003
C++
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; cin>>N>>M; struct Line { int t,c,i; }; vector<Line> graph[N]; for (int i = 0; i < M; i++) { int p,q,c; cin>>p>>q>>c; p--,q--; graph[p].push_back({q,c,i}); graph[q].push_back({p,c,i}); } vector<bool> used(M, false); int ans = numeric_limits<int>::max(); function<void(int,int,int)> dfs = [&](int s, int c, int v) { if (q.s == N-1) { ans = min(ans, q.v); return; } for (auto& line : graph[q.s]) { if (used[line.i]) continue; used[line.i] = true; dfs(line.t, line.c, q.v+(q.c != line.c ? 1 : 0)); } }; dfs(0,0,0); if (ans == numeric_limits<int>::max()) ans = -1; cout << ans << endl; return 0; }
a.cc: In lambda function: a.cc:24:13: error: 'q' was not declared in this scope 24 | if (q.s == N-1) { | ^ a.cc:28:33: error: 'q' was not declared in this scope 28 | for (auto& line : graph[q.s]) { | ^
s153076923
p04003
C++
#include <bits/stdc++.h> #define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++) #define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--) #define sz(v) (int)(v).size() #define pb push_back #define sc second #define fr first #define sor(v) sort(v.begin(),v.end()) #define rev(s) reverse(s.begin(),s.end()) #define lb(vec,a) lower_bound(vec.begin(),vec.end(),a) #define ub(vec,a) upper_bound(vec.begin(),vec.end(),a) #define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end()) using namespace std; typedef long long int ll; typedef pair <int, int> P; const ll MOD=1000000007; const int MAX_V=100000; const int INF=10000000; struct edge {int to, label; }; int V,M; vector <edge> G[MAX_V]; int d[MAX_V]; priority_queue<P, vector<P>, greater<P>> que; unordered_map<P, int> m; void dfs(int p, int x, int l){ m[P(x,l)]=1; for(auto &e: G[x]){ if(e.to!=p&&e.label==l){ d[e.to]=min(d[e.to], d[x]); que.push(P(d[e.to], e.to)); dfs(x,e.to,l); } } } void dijkstra (int s){ fill(d,d+V,INF); d[s]=0; que.push(P(0,s)); while (!que.empty()) { P p=que.top(); que.pop(); int v=p.second; if (d[v]<p.first) continue; for(auto &e: G[v]){ if(d[e.to]>d[v]+1){ d[e.to]=d[v]+1; que.push(P(d[e.to], e.to)); dfs(v,e.to,e.label); } else if(d[e.to]==d[v]+1){ if(m[P(e.to, e.label)]!=1) dfs(v,e.to,e.label); } } } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>V>>M; rep(i,0,M){ int p,q,c; cin>>p>>q>>c; p--; q--; G[p].pb(edge{q,c}); G[q].pb(edge{p,c}); } dijkstra(0); cout <<(d[V-1]==INF?-1:d[V-1])<<"\n"; }
a.cc:26:23: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 26 | unordered_map<P, int> m; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::
s330014705
p04003
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(x) ((int)x.size()) #define sqr(x) ((x)*(x)) #define mem(a) memset(a,0,sizeof(a)) #define all(x) x.begin(),x.end() typedef vector<int> vi; typedef pair<int, int> pii; typedef long long ll; const int mn = 5e5 + 5; const int mod = 1e9 + 7; struct edge { int to, dist; }; template<> struct hash<pii> { size_t operator()(const pii &s) const { size_t out = 14695981039346656037ULL; static const size_t mul = 1099511628211ULL; out = (out ^ s.first) * mul; out = (out ^ s.second) * mul; return out; } }; int n, m; unordered_map<pii, int> h; int cnt; vector<edge> g[mn]; int ans; inline void add_edge(int u, int v, int w) { int u1, v1; pii p{u, w}; if (!h.count(p)) { h[p] = ++cnt; g[cnt].pb({u, 1}); g[u].pb({cnt, 1}); } u1 = h[p]; p = make_pair(v, w); if (!h.count(p)) { h[p] = ++cnt; g[cnt].pb({v, 1}); g[v].pb({cnt, 1}); } v1 = h[p]; g[u1].pb({v1, 0}); g[v1].pb({u1, 0}); } struct node { int id, dist; bool operator<(const node &p) const { return dist > p.dist; } }; int dist[mn]; priority_queue<node> q; void dijk(int s, int t) { memset(dist, 1, sizeof dist); q.push({s, dist[s] = 0}); while (!q.empty()) { node u = q.top(); q.pop(); if (dist[u.id] < u.dist) continue; for (auto &i:g[u.id]) { int nxtdist = i.dist + u.dist; if (dist[i.to] > nxtdist) { dist[i.to] = nxtdist; q.push({i.to, nxtdist}); } } } } int main() { #ifdef LOCAL freopen("../1.txt", "r", stdin); freopen("../2.txt", "w", stdout); #endif scanf("%d%d", &n, &m); cnt = n; for (int i = 1; i <= m; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); add_edge(u, v, w); } dijk(1, n); ans = dist[n]; if (ans > 1e7) { ans = -2; } printf("%d\n", ans/2); }
a.cc:22:8: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive] 22 | struct hash<pii> { | ^~~~~~~~~
s593764799
p04003
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long const int MOD = 1E9+7; const int N = 1000000+5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {-1,1,0,0,-1,1,-1,1}; using namespace std; struct Edge { int to,next,val; Edge(){} Edge(int to,int next,int val):to(to),next(next),val(val){} bool operator < (const Edge& rhs)const{ return val>rhs.val; } }edge[N*2]; int tot,head[N]; void addEdge(int from,int to,int val) { edge[tot].next=head[from]; edge[tot].to=to; edge[tot].val=val; head[from]=tot++; } bool vis[N]; int dis[N]; int SPFA(int s,int e) { memset(vis,false,sizeof(vis)); memset(dis,INF,sizeof(dis)); dis[s]=0; queue<Edge> Q; Q.push(Edge(s,0,0)); while (!Q.empty()) { Edge temp=Q.top(); Q.pop(); if(vis[temp.to]) continue; vis[temp.to]=true; for(int i=head[temp.to]; i!=-1; i=edge[i].next) { if(dis[edge[i].to]>dis[temp.to]+edge[i].val) { dis[edge[i].to]=dis[temp.to]+edge[i].val; Q.push(Edge(edge[i].to,0,dis[edge[i].to])); } } } if(dis[e]!=INF) return dis[e]/2; return -1; } map<int,int> mp[N]; int allPoint; int getPoint(int x,int y) { if (!mp[x][y]) mp[x][y]=++allPoint; return mp[x][y]; } int main() { int n,m; scanf("%d%d",&n,&m); memset(head,-1,sizeof(head)); allPoint=n; for (int i=1; i<=m; i++) { int x,y,w; scanf("%d%d%d",&x,&y,&w); int newX=getPoint(x,w); int newY=getPoint(y,w); addEdge(x,newX,1); addEdge(newX,x,1); addEdge(newX,newY,0); addEdge(newY,newX,0); addEdge(y,newY,1); addEdge(newY,y,1); } int res=SPFA(1,n); printf("%d\n",res); return 0; }
a.cc: In function 'int SPFA(int, int)': a.cc:49:21: error: 'class std::queue<Edge>' has no member named 'top'; did you mean 'pop'? 49 | Edge temp=Q.top(); | ^~~ | pop
s148838260
p04003
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long const int MOD = 1E9+7; const int N = 1000000+5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {-1,1,0,0,-1,1,-1,1}; using namespace std; struct Edge { int to,next,val; Edge(){} Edge(int to,int next,int val):to(to),next(next),val(val){} bool operator < (const Edge& rhs)const{ return val>rhs.val; } }edge[N*2]; int tot,head[N]; void addEdge(int from,int to,int val) { edge[tot].next=head[from]; edge[tot].to=to; edge[tot].val=val; head[from]=tot++; } bool vis[N]; int dis[N]; void SPFA(int s,int e) { memset(vis,false,sizeof(vis)); memset(dis,INF,sizeof(dis)); dis[s]=0; priority_queue<Edge> Q; Q.push(Edge(s,0,0)); while (!Q.empty()) { Edge temp=Q.top(); Q.pop(); if(vis[temp.to]) continue; vis[temp.to]=true; for(int i=head[temp.to]; i!=-1; i=edge[i].next) { if(dis[edge[i].to]>dis[temp.to]+edge[i].val) { dis[edge[i].to]=dis[temp.to]+edge[i].val; Q.push(Edge(edge[i].to,0,dis[edge[i].to])); } } } if(dis[e]!=INF) return dis[e]/2; return -1; } map<int,int> mp[N]; int allPoint; int getPoint(int x,int y) { if (!mp[x][y]) mp[x][y]=++allPoint; return mp[x][y]; } int main() { int n,m; scanf("%d%d",&n,&m); memset(head,-1,sizeof(head)); allPoint=n; for (int i=1; i<=m; i++) { int x,y,w; scanf("%d%d%d",&x,&y,&w); int newX=getPoint(x,w); int newY=getPoint(y,w); addEdge(x,newX,1); addEdge(newX,x,1); addEdge(newX,newY,0); addEdge(newY,newX,0); addEdge(y,newY,1); addEdge(newY,y,1); } SPFA(1,n); return 0; }
a.cc: In function 'void SPFA(int, int)': a.cc:63:22: error: return-statement with a value, in function returning 'void' [-fpermissive] 63 | return dis[e]/2; | ~~~~~~^~ a.cc:64:12: error: return-statement with a value, in function returning 'void' [-fpermissive] 64 | return -1; | ^~
s787293877
p04003
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long const int MOD = 1E9+7; const int N = 2000000+5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {-1,1,0,0,-1,1,-1,1}; using namespace std; struct Edge{ int to,next; int val; Edge(){} Edge(int to,int next,int val):to(to),next(next),val(val){} bool operator < (const Edge &rhs)const{ val>rhs.val; } }edge[N*2]; int head[N*2],tot; bool vis[N*2]; int dis[N]; void addEdge(int from,int to,int val){ edge[tot].next=head[from]; edge[tot].to=to; edge[tot].val=val; head[from]=tot++; } int SPFA(int s,int e){ memset(vis,false,sizeof(vis)); memset(dis,INF,sizeof(dis)); dis[s]=0; priority_queue<Edge> Q; Q.push(Edge(s,0,0)); while(!Q.empty()){ Edge temp=Q.front(); Q.pop(); if(!vis[temp.to]){ vis[temp.to]=true; for(int i=head[temp.to];i!=-1;i=edge[i].next){ if(dis[edge[i].to]>dis[temp.to]+edge[i].val){ dis[edge[i].to]=dis[temp.to]+edge[i].val; Q.push(Edge(edge[i].to,0,dis[edge[i].to])); } } } } if(dis[e]==INF) return -1; return dis[e]/2; } map<int,int> mp[N]; int allPoint; int getPoint(int x,int y){ if(!mp[x][y]){ allPoint++; mp[x][y]=allPoint; } return mp[x][y]; } int main(){ int n,m; scanf("%d%d",&n,&m); allPoint=n; memset(head,-1,sizeof(head)); for(int i=1;i<=m;i++){ int x,y,w; scanf("%d%d%d",&x,&y,&w); int newX=getPoint(x,w); int newY=getPoint(y,w); addEdge(x,newX,1); addEdge(newX,x,1); addEdge(newX,newY,0); addEdge(newY,newX,0); addEdge(newY,y,1); addEdge(y,newY,1); } int res=SPFA(1,n); printf("%d\n",res); return 0; }
a.cc: In member function 'bool Edge::operator<(const Edge&) const': a.cc:31:5: warning: no return statement in function returning non-void [-Wreturn-type] 31 | } | ^ a.cc: In function 'int SPFA(int, int)': a.cc:50:21: error: 'class std::priority_queue<Edge>' has no member named 'front' 50 | Edge temp=Q.front(); | ^~~~~
s133166355
p04003
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define pb push_back #define mp make_pair main(){ int N, M; cin >> N >> M; vector<pair<int, int>> edge[100000]; rep(i, m){ int A, B, C; cin >> A >> B >> C; edge[A-1].pb(mp(B-1, C)); edge[B-1].pb(mp(A-1, C)); } map<int, int> cost[100000]; priority_queue<pair<int,pair<int,int>>> que; for(int i=0; i<edge[0].size(); i++){ cost[0][edge[0][i].second] = 0; que.push({ 0,{0,edge[0][i].second} }); } while(!que.empty()){ int c = -que.top().first; int v = que.top().second.first; int t = que.top().second.second; que.pop(); for(int i=0; i<edge[v].size(); i++){ if(cost[edge[v][i].first].count(edge[v][i].second) == 0 || cost[edge[v][i].first][edge[v][i].second] > c+(edge[v][i].second==t ? 0 : 1)){ cost[edge[v][i].first][edge[v][i].second] = c+(edge[v][i].second==t ? 0 : 1); que.push({ -cost[edge[v][i].first][edge[v][i].second],{edge[v][i].first,edge[v][i].second} }); } } } int ans = INT_MAX; for(auto itr=cost[N-1].begin(); itr!=cost[N-1].end(); itr++) ans = min(ans, itr->second); if(ans == INT_MAX) cout << -1 << endl; else cout << ans + 1 << endl; }
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:12:16: error: 'm' was not declared in this scope 12 | rep(i, m){ | ^ a.cc:4:39: note: in definition of macro 'rep' 4 | #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) | ^
s287998411
p04003
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include <fstream> #include <time.h> #include <atltime.h> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); #define int long long #define all(x) (x).begin(), (x).end() using namespace std; int MAX = 100010; int MOD = (ll)1000000000 + 7; ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pair<int, int>P;//firstは距離、secondは頂点番号 struct Ver { int dist; set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる struct edge { int to, cmp; };//辺には行き先の頂点と会社を持たせる Ver d[100010]; int V;//頂点数 int M;//辺の本数 vector<edge>G[100010];//グラフ //int d[MAX];//始点からの距離 void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; //全点への距離をINFで初期化 for (int i = 0; i < V + 1; i++) { d[i].dist = INF; } //始点への距離は0 d[s].dist = 0; //始点をキューに入れる que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second;//今見ている頂点 if (d[v].dist < p.first)continue; //今見ている頂点につながるすべての辺について距離を更新する for (int i = 0; i < G[v].size(); i++) { edge e = G[v][i]; int cost = 1; //vに訪れるのに最後に使った会社(複数の場合もある)が今見ている辺の会社と同じならコストを0にする if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; //今見ている辺を使うことでe.toへの距離が小さくなるなら、距離を更新し、最後に使った会社をe.cmpとする if (d[e.to].dist > d[v].dist + cost) { set<int>st; st.insert(e.cmp); d[e.to] = { d[v].dist + cost,{ e.cmp } }; que.push(P(d[e.to].dist, e.to)); } //今見ている辺を使っても距離が変わらない場合、最後に使った会社に(もしe.cmpがなかったら)e.cmpを追加する else if (d[e.to].dist == d[v].dist + cost) { if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { d[e.to].company.insert(e.cmp); //que.push(P(d[e.to].dist, e.to)); } } } } } signed main() { //std::ifstream in("22.txt"); //std::cin.rdbuf(in.rdbuf()); cin >> V >> M; //CFileTime cTimeStart, cTimeEnd; //CFileTimeSpan cTimeSpan; //cTimeStart = CFileTime::GetCurrentTime(); // 現在時刻 for (int i = 0; i < M; i++) { int p, q, c; cin >> p >> q >> c; G[p].push_back({ q,c }); G[q].push_back({ p,c }); } dijkstra(1); //cout << "dijkstra" << endl; ll ans = d[V].dist; if (ans == INF) { cout << -1 << endl; return 0; } cout << ans << endl; //cTimeEnd = CFileTime::GetCurrentTime(); // 現在時刻 //cTimeSpan = cTimeEnd - cTimeStart; //std::cout << "処理時間:" << cTimeSpan.GetTimeSpan() / 10000 << "[ms]" << std::endl; }
a.cc:19:10: fatal error: atltime.h: No such file or directory 19 | #include <atltime.h> | ^~~~~~~~~~~ compilation terminated.
s127557809
p04003
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include <fstream> #include <time.h> #include <atltime.h> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); #define int long long #define all(x) (x).begin(), (x).end() using namespace std; int MAX = 100010; int MOD = (ll)1000000000 + 7; ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pair<int, int>P;//firstは距離、secondは頂点番号 struct Ver { int dist; set<int>company; };//頂点に、始点からの距離と最後に使った会社を持たせる struct edge { int to, cmp; };//辺には行き先の頂点と会社を持たせる Ver d[100010]; int V;//頂点数 int M;//辺の本数 vector<edge>G[100010];//グラフ //int d[MAX];//始点からの距離 void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; //全点への距離をINFで初期化 for (int i = 0; i < V + 1; i++) { d[i].dist = INF; } //始点への距離は0 d[s].dist = 0; //始点をキューに入れる que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second;//今見ている頂点 if (d[v].dist < p.first)continue; //今見ている頂点につながるすべての辺について距離を更新する for (int i = 0; i < G[v].size(); i++) { edge e = G[v][i]; int cost = 1; //vに訪れるのに最後に使った会社(複数の場合もある)が今見ている辺の会社と同じならコストを0にする if (d[v].company.find(e.cmp) != d[v].company.end())cost = 0; //今見ている辺を使うことでe.toへの距離が小さくなるなら、距離を更新し、最後に使った会社をe.cmpとする if (d[e.to].dist > d[v].dist + cost) { set<int>st; st.insert(e.cmp); d[e.to] = { d[v].dist + cost,{ e.cmp } }; que.push(P(d[e.to].dist, e.to)); } //今見ている辺を使っても距離が変わらない場合、最後に使った会社に(もしe.cmpがなかったら)e.cmpを追加する else if (d[e.to].dist == d[v].dist + cost) { if (d[e.to].company.find(e.cmp) == d[e.to].company.end()) { d[e.to].company.insert(e.cmp); //que.push(P(d[e.to].dist, e.to)); } } } } } signed main() { //std::ifstream in("22.txt"); //std::cin.rdbuf(in.rdbuf()); cin >> V >> M; //CFileTime cTimeStart, cTimeEnd; //CFileTimeSpan cTimeSpan; //cTimeStart = CFileTime::GetCurrentTime(); // 現在時刻 for (int i = 0; i < M; i++) { int p, q, c; cin >> p >> q >> c; G[p].push_back({ q,c }); G[q].push_back({ p,c }); } dijkstra(1); //cout << "dijkstra" << endl; ll ans = d[V].dist; if (ans == INF) { cout << -1 << endl; return 0; } cout << ans << endl; //cTimeEnd = CFileTime::GetCurrentTime(); // 現在時刻 //cTimeSpan = cTimeEnd - cTimeStart; //std::cout << "処理時間:" << cTimeSpan.GetTimeSpan() / 10000 << "[ms]" << std::endl; }
a.cc:19:10: fatal error: atltime.h: No such file or directory 19 | #include <atltime.h> | ^~~~~~~~~~~ compilation terminated.
s228610522
p04003
C++
8 11 1 3 1 1 4 2 2 3 1 2 5 1 3 4 3 3 6 3 3 7 3 4 8 4 5 6 1 6 7 5 7 8 5
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 8 11 | ^
s965551551
p04003
C++
#include <bits/stdc++.h> #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" #define NDEBUG #define SHOW(...) static_cast<void>(0) //!===========================================================!// //! dP dP dP !// //! 88 88 88 !// //! 88aaaaa88a .d8888b. .d8888b. .d888b88 .d8888b. 88d888b. !// //! 88 88 88ooood8 88' '88 88' '88 88ooood8 88' '88 !// //! 88 88 88. ... 88. .88 88. .88 88. ... 88 !// //! dP dP '88888P' '88888P8 '88888P8 '88888P' dP !// //!===========================================================!// using ld = long double; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr unsigned int MOD = 1000000007; template <typename T> constexpr T INF = std::numeric_limits<T>::max() / 4; template <typename F> constexpr F PI = static_cast<F>(3.1415926535897932385); std::mt19937 mt{std::random_device{}()}; template <typename T> bool chmin(T& a, const T& b) { return a = std::min(a, b), a == b; } template <typename T> bool chmax(T& a, const T& b) { return a = std::max(a, b), a == b; } template <typename T> std::vector<T> Vec(const std::size_t n, T v) { return std::vector<T>(n, v); } template <class... Args> auto Vec(const std::size_t n, Args... args) { return std::vector<decltype(Vec(args...))>(n, Vec(args...)); } template <typename T> constexpr T popCount(const T u) { #ifdef __has_builtin return u == 0 ? T(0) : (T)__builtin_popcountll(u); #else unsigned long long v = static_cast<unsigned long long>(u); return v = (v & 0x5555555555555555ULL) + (v >> 1 & 0x5555555555555555ULL), v = (v & 0x3333333333333333ULL) + (v >> 2 & 0x3333333333333333ULL), v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL, static_cast<T>(v * 0x0101010101010101ULL >> 56 & 0x7f); #endif } template <typename T> constexpr T log2p1(const T u) { #ifdef __has_builtin return u == 0 ? T(0) : T(64 - __builtin_clzll(u)); #else unsigned long long v = static_cast<unsigned long long>(u); return v = static_cast<unsigned long long>(v), v |= (v >> 1), v |= (v >> 2), v |= (v >> 4), v |= (v >> 8), v |= (v >> 16), v |= (v >> 32), popCount(v); #endif } template <typename T> constexpr T clog(const T v) { return v == 0 ? T(0) : log2p1(v - 1); } template <typename T> constexpr T msbp1(const T v) { return log2p1(v); } template <typename T> constexpr T lsbp1(const T v) { #ifdef __has_builtin return __builtin_ffsll(v); #else return v == 0 ? T(0) : popCount((v & (-v)) - T(1)) + T(1); #endif } template <typename T> constexpr bool ispow2(const T v) { return popCount(v) == 1; } template <typename T> constexpr T ceil2(const T v) { return v == 0 ? T(1) : T(1) << log2p1(v - 1); } template <typename T> constexpr T floor2(const T v) { return v == 0 ? T(0) : T(1) << (log2p1(v) - 1); } //!=======================================================================================!// //! a88888b. dP .88888. dP !// //! d8' '88 88 d8' '88 88 !// //! 88 .d8888b. .d8888b. d8888P 88 88d888b. .d8888b. 88d888b. 88d888b. !// //! 88 88' '88 Y8ooooo. 88 88 YP88 88' '88 88' '88 88' '88 88' '88 !// //! Y8. .88 88. .88 88 88 Y8. .88 88 88. .88 88. .88 88 88 !// //! Y88888P' '88888P' '88888P' dP '88888' dP '88888P8 88Y888P' dP dP !// //! 88 !// //! dP !// //!=======================================================================================!// template <typename T> struct CostGraph { CostGraph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {} void addEdge(const std::size_t from, const std::size_t to, const T cost, const bool bi = false) { assert(from < V), assert(to < V); edge[from].push_back(Edge{to, cost}), rev_edge[to].push_back(Edge(from, cost)); if (bi) { addEdge(to, from, cost, false); } } struct Edge { Edge(const std::size_t to, const T cost) : to{to}, cost{cost} {} const std::size_t to; const T cost; bool operator<(const Edge& e) const { return cost != e.cost ? cost < e.cost : to < e.to; } }; const std::vector<Edge>& operator[](const std::size_t i) const { return assert(i < V), edge[i]; } friend std::ostream& operator<<(std::ostream& os, const CostGraph& g) { os << "[\n"; for (std::size_t i = 0; i < g.V; i++) { for (const auto& e : g.edge[i]) { os << i << "->" << e.to << ":" << e.cost << "\n"; } } return (os << "]\n"); } const std::size_t V; std::vector<std::vector<Edge>> edge, rev_edge; }; //!============================================!// //! 8888ba.88ba oo !// //! 88 '8b '8b !// //! 88 88 88 .d8888b. dP 88d888b. !// //! 88 88 88 88' '88 88 88' '88 !// //! 88 88 88 88. .88 88 88 88 !// //! dP dP dP '88888P8 dP dP dP !// //!============================================!// int main() { int N, M; std::cin >> N >> M; CostGraph<int> G(N); for (int i = 0, a, b, c; i < M; i++) { std::cin >> a >> b >> c, a--, b--, G.addEdge(a, b, c, true); } using T = int; auto Dijkstra = [&](const CostGraph<T>& g, const int s, const int c) { using P = std::pair<int, int>; std::map<P, int> d; using PP = std::pair<T, P>; std::priority_queue<PP, std::vector<PP>, std::greater<PP>> q; d[{s, c}] = 0, q.push({0, {s, c}}); while (not q.empty()) { const T cost = q.top().first; const int v = q.top().second.first; const int c = q.top().second.second; q.pop(); if (d.find({v, c}) != d.end() and d[{v, c}] < cost) { continue; } for (const auto& e : g.edge[v]) { if (c == 0 or e.cost == c) { if (d.find({e.to, e.cost}) != d.end() and d[{e.to, e.cost}] <= cost) { continue; } d[{e.to, e.cost}] = cost, q.push({cost, {e.to, e.cost}}); } else { if (d.find({e.to, e.cost}) != d.end() and d[{e.to, e.cost}] <= cost + 1) { continue; } d[{e.to, e.cost}] = cost + 1, q.push({cost + 1, {e.to, e.cost}}); } } } return d; }; const auto D = Dijkstra(G, 0, 0); int ans = INF<int>; for (int i = 0; i <= 100000; i++) { if (D.find({N - 1, i}) != D.end()) { chmin(ans, D.at({N - 1, i})); } } std::cout << (ans == INF<int> ? -1 : (ans + 1) * K) << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:154:54: error: 'K' was not declared in this scope 154 | std::cout << (ans == INF<int> ? -1 : (ans + 1) * K) << std::endl; | ^
s548725717
p04003
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Queue; import java.util.Set; import java.util.StringTokenizer; /** * Created by darshan on 3/28/19. */ public class C061 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; st = new StringTokenizer(br.readLine()); int numStations = Integer.parseInt(st.nextToken()); int numLines = Integer.parseInt(st.nextToken()); List<List<Edge>> edges = new ArrayList<>(numStations); List<Set<Integer>> visitedFrom = new ArrayList<>(); for (int i = 0; i < numStations; i++) { edges.add(new ArrayList<>()); visitedFrom.add(new HashSet<>()); } int[] minCost = new int[numStations]; Arrays.fill(minCost, Integer.MAX_VALUE); minCost[0] = 0; for (int i = 0; i < numLines; i++) { st = new StringTokenizer(br.readLine()); int stationP = Integer.parseInt(st.nextToken()) - 1; int stationQ = Integer.parseInt(st.nextToken()) - 1; int company = Integer.parseInt(st.nextToken()); edges.get(stationP).add(new Edge(stationQ, company)); edges.get(stationQ).add(new Edge(stationP, company)); } Queue<Integer> queue = new ArrayDeque<>(); queue.add(0); while (!queue.isEmpty()) { int station = queue.poll(); if (station == numStations - 1) { System.out.println(minCost[station]); return; } for (Edge edge : edges.get(station)) { int cost = minCost[station]; if (!visitedFrom.get(station).contains(edge.company)) { cost += 1; } if (minCost[edge.station] > cost) { queue.add(edge.station); } if (minCost[edge.station] >= cost) { minCost[edge.station] = cost; visitedFrom.get(edge.station).add(edge.company); } } } System.out.println(-1); } private static class Edge { private int station; private int company; private Edge(int station, int company) { this.station = station; this.company = company; } } }
Main.java:16: error: class C061 is public, should be declared in a file named C061.java public class C061 { ^ 1 error
s783379160
p04003
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #include<stdio.h> #include<algorithm> #include<string.h> #include<vector> #include<queue> using namespace std; vector<pair<int,int> > g[110000]; vector<pair<int,int> > G[310000]; int v[310000]; int ijk[310000]; int main(){ int a,b;scanf("%d%d",&a,&b); for(int i=0;i<b;i++){ int p,q,r;scanf("%d%d%d",&p,&q,&r); p--;q--; g[p].push_back(make_pair(r,i)); g[q].push_back(make_pair(r,i)); G[i].push_back(make_pair(b+p,0)); G[i].push_back(make_pair(b+q,0)); G[b+p].push_back(make_pair(i,1)); G[b+q].push_back(make_pair(i,1)); } for(int i=0;i<a;i++){ if(g[i].size()==0)continue; std::sort(g[i].begin(),g[i].end()); int st=0; for(int j=0;j<g[i].size();j++){ if(j&&g[i][j].first!=g[i][j-1].first){ for(int k=st;k<j-1;k++){ G[g[i][k].second].push_back(make_pair(g[i][k+1].second,0)); } G[g[i][j-1].second].push_back(make_pair(g[i][st].second,0)); st=j; } } for(int k=st;k<g[i].size()-1;k++){ G[g[i][k].second].push_back(make_pair(g[i][k+1].second,0)); } G[g[i][g[i].size()-1].second].push_back(make_pair(g[i][st].second,0)); } for(int i=0;i<310000;i++)ijk[i]=999999999; ijk[b]=0; priority_queue<pair<int,int> > Q; Q.push(make_pair(0,b)); while(Q.size()){ int cost=-Q.top().first; int at=Q.top().second; Q.pop(); if(v[at])continue; v[at]=1; for(int i=0;i<G[at].size();i++){ int to=G[at][i].first; int tc=cost+G[at][i].second; if(!v[to]&&ijk[to]>tc){ ijk[to]=tc;Q.push(make_pair(-tc,to)); } } } if(ijk[b+a-1]>99999999)printf("-1\n"); else printf("%d\n",ijk[b+a-1]); }
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^ 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:63: /usr/include/stdlib.h:98:8: error: 'size_t' does not name a type 98 | extern size_t __ctype_get_mb_cur_max (void) __THROW __wur; | ^~~~~~ /usr/include/stdlib.h:42:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 41 | # include <bits/waitstatus.h> +++ |+#include <cstddef> 42 | /usr/include/stdlib.h:278:36: error: 'size_t' has not been declared 278 | extern int strfromd (char *__dest, size_t __size, const char *__format, | ^~~~~~ /usr/include/stdlib.h:282:36: error: 'size_t' has not been declared 282 | extern int strfromf (char *__dest, size_t __size, const char *__format, | ^~~~~~ /usr/include/stdlib.h:286:36: error: 'size_t' has not been declared 286 | extern int strfroml (char *__dest, size_t __size, const char *__format, | ^~~~~~ /usr/include/stdlib.h:298:38: error: 'size_t' has not been declared 298 | extern int strfromf32 (char *__dest, size_t __size, const char * __format, | ^~~~~~ /usr/include/stdlib.h:304:38: error: 'size_t' has not been declared 304 | extern int strfromf64 (char *__dest, size_t __size, const char * __format, | ^~~~~~ /usr/include/stdlib.h:310:39: error: 'size_t' has not been declared 310 | extern int strfromf128 (char *__dest, size_t __size, const char * __format, | ^~~~~~ /usr/include/stdlib.h:316:39: error: 'size_t' has not been declared 316 | extern int strfromf32x (char *__dest, size_t __size, const char * __format, | ^~~~~~ /usr/include/stdlib.h:322:39: error: 'size_t' has not been declared 322 | extern int strfromf64x (char *__dest, size_t __size, const char * __format, | ^~~~~~ In file included from /usr/include/stdlib.h:514: /usr/include/x86_64-linux-gnu/sys/types.h:33:9: error: '__u_char' does not name a type 33 | typedef __u_char u_char; | ^~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:34:9: error: '__u_short' does not name a type 34 | typedef __u_short u_short; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:35:9: error: '__u_int' does not name a type 35 | typedef __u_int u_int; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:36:9: error: '__u_long' does not name a type 36 | typedef __u_long u_long; | ^~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:37:9: error: '__quad_t' does not name a type 37 | typedef __quad_t quad_t; | ^~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:38:9: error: '__u_quad_t' does not name a type 38 | typedef __u_quad_t u_quad_t; | ^~~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:39:9: error: '__fsid_t' does not name a type 39 | typedef __fsid_t fsid_t; | ^~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:42:9: error: '__loff_t' does not name a type; did you mean '__locale_t'? 42 | typedef __loff_t loff_t; | ^~~~~~~~ | __locale_t /usr/include/x86_64-linux-gnu/sys/types.h:47:9: error: '__ino_t' does not name a type 47 | typedef __ino_t ino_t; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:54:9: error: '__ino64_t' does not name a type 54 | typedef __ino64_t ino64_t; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:59:9: error: '__dev_t' does not name a type 59 | typedef __dev_t dev_t; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:64:9: error: '__gid_t' does not name a type 64 | typedef __gid_t gid_t; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:69:9: error: '__mode_t' does not name a type; did you mean '__locale_t'? 69 | typedef __mode_t mode_t; | ^~~~~~~~ | __locale_t /usr/include/x86_64-linux-gnu/sys/types.h:74:9: error: '__nlink_t' does not name a type 74 | typedef __nlink_t nlink_t; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:79:9: error: '__uid_t' does not name a type 79 | typedef __uid_t uid_t; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:97:9: error: '__pid_t' does not name a type 97 | typedef __pid_t pid_t; | ^~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:103:9: error: '__id_t' does not name a type 103 | typedef __id_t id_t; | ^~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:114:9: error: '__daddr_t' does not name a type 114 | typedef __daddr_t daddr_t; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:115:9: error: '__caddr_t' does not name a type 115 | typedef __caddr_t caddr_t; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:121:9: error: '__key_t' does not name a type 121 | typedef __key_t key_t; | ^~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:126: /usr/include/x86_64-linux-gnu/bits/types/clock_t.h:7:9: error: '__clock_t' does not name a type 7 | typedef __clock_t clock_t; | ^~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:128: /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:7:9: error: '__clockid_t' does not name a type 7 | typedef __clockid_t clockid_t; | ^~~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:129: /usr/include/x86_64-linux-gnu/bits/types/time_t.h:10:9: error: '__time_t' does not name a type 10 | typedef __time_t time_t; | ^~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:130: /usr/include/x86_64-linux-gnu/bits/types/timer_t.h:7:9: error: '__timer_t' does not name a type 7 | typedef __timer_t timer_t; | ^~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:134:9: error: '__useconds_t' does not name a type 134 | typedef __useconds_t useconds_t; | ^~~~~~~~~~~~ /usr/include/x86_64-linux-gnu/sys/types.h:138:9: error: '__suseconds_t' does not name a type 138 | typedef __suseconds_t suseconds_t; | ^~~~~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155: /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:24:9: error: '__int8_t' does not name a type; did you mean '__int128_t'? 24 | typedef __int8_t int8_t; | ^~~~~~~~ | __int128_t /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:25:9: error: '__int16_t' does not name a type; did you mean '__int128_t'? 25 | typedef __int16_t int16_t; | ^~~~~~~~~ | __int128_t /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:9: error: '__int32_t' does not name a type; did you mean '__int128_t'? 26 | typedef __int32_t int32_t; | ^~~~~~~~~ | __int128_t /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:9: error: '__int64_t' does not name a type; did you mean '__int128_t'? 27 | typedef __int64_t int64_t; | ^~~~~~~~~ | __int128_t /usr/include/x86_64-linux-gnu/sys/types.h:158:9: error: '__uint8_t' does not name a type; did you mean '__uint128_t'? 158 | typedef __uint8_t u_int8_t; | ^~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/sys/types.h:159:9: error: '__uint16_t' does not name a type; did you mean '__uint128_t'? 159 | typedef __uint16_t u_int16_t; | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/sys/types.h:160:9: error: '__uint32_t' does not name a type; did you mean '__uint128_t'? 160 | typedef __uint32_t u_int32_t; | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/sys/types.h:161:9: error: '__uint64_t' does not name a type; did you mean '__uint128_t'? 161 | typedef __uint64_t u_int64_t; | ^~~~~~~~~~ | __uint128_t In file included from /usr/include/endian.h:35, from /usr/include/x86_64-linux-gnu/sys/types.h:176: /usr/include/x86_64-linux-gnu/bits/byteswap.h:33:17: error: '__uint16_t' does not name a type; did you mean '__uint128_t'? 33 | static __inline __uint16_t | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/bits/byteswap.h:48:17: error: '__uint32_t' does not name a type; did you mean '__uint128_t'? 48 | static __inline __uint32_t | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/bits/byteswap.h:69:31: error: '__uint64_t' does not name a type; did you mean '__uint128_t'? 69 | __extension__ static __inline __uint64_t | ^~~~~~~~~~ | __uint128_t In file included from /usr/include/endian.h:36: /usr/include/x86_64-linux-gnu/bits/uintn-identity.h:32:17: error: '__uint16_t' does not name a type; did you mean '__uint128_t'? 32 | static __inline __uint16_t | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/bits/uintn-identity.h:38:17: error: '__uint32_t' does not name a type; did you mean '__uint128_t'? 38 | static __inline __uint32_t | ^~~~~~~~~~ | __uint128_t /usr/include/x86_64-linux-gnu/bits/uintn-identity.h:44:17: error: '__uint64_t' does not name a type; did you mean '__uint128_t'? 44 | static __inline __uint64_t | ^~~~~~~~~~ | __uint128_t In file included from /usr/include/x86_64-linux-gnu/sys/select.h:37, from /usr/include/x86_64-linux-gnu/sys/types.h:179: /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:14:3: error: '__time_t' does not name a type; did you mean '__sigset_t'? 14 | __time_t tv_sec; /* Seconds. */ |
s050436529
p04003
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; typedef unsigned int uint; using namespace std; int N, M, inf=a#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; typedef unsigned int uint; using namespace std; int N, M, inf=1e9; typedef pair<int, int> P; typedef pair<int, P> PP; map <P, vector<PP>> mp; map <P, int> cost; void dijkstra(P start){ priority_queue < PP, vector<PP>, greater<PP> > q; for (auto itr = mp.begin(); itr != mp.end(); itr++) { cost[itr->first] = inf; } cost[start] = 0; q.push(PP(0, start)); while (q.size()) { PP p = q.top(); q.pop(); P current_station = p.second; for (PP next : mp[current_station]) { P next_station = next.second; int c = next.first; if (cost[next_station] > cost[current_station] + c) { cost[next_station] = cost[current_station] + c; q.push(PP(cost[next_station], next_station)); } } } } int main() { cin.sync_with_stdio(false); cin.tie(0); cin >> N >> M; for (int i = 0; i < M; i++) { int p, q, c; cin >> p >> q >> c; mp[P(p, 0)].push_back(PP(1, P(p, c))); // 駅pで路線cに入る mp[P(p, c)].push_back(PP(0, P(q, c))); // 路線cでp->q mp[P(q, c)].push_back(PP(0, P(q, 0))); // 駅qで路線cから出る mp[P(q, 0)].push_back(PP(1, P(q, c))); // 駅qで路線cに入る mp[P(q, c)].push_back(PP(0, P(p, c))); // 路線cでq->p mp[P(p, c)].push_back(PP(0, P(p, 0))); // 駅pで路線cから出る } dijkstra(P(1, 0)); int ans = cost[P(N, 0)] == 0 || cost[P(N, 0)] == inf ? -1 : cost[P(N, 0)]; cout << ans << "\n"; return 0; }; typedef pair<int, int> P; typedef pair<P, int> PP; map <P, vector<PP>> mp; map <P, int> cost; void dijkstra(P start){ priority_queue < P, vector<P>, greater<P> > q; map<P, vector<PP>>::iterator itr; for (itr = mp.begin(); itr != mp.end(); itr++) cost[itr->first] = inf; cost[start] = 0; q.push(start); while (q.size()) { P current_station = q.top(); q.pop(); for (PP next : mp[current_station]) { P next_station = next.first; int c = next.second; if (cost[next_station] > cost[current_station] + c) { cost[next_station] = cost[current_station] + c; q.push(next_station); } } } } int main() { cin.sync_with_stdio(false); cin.tie(0); cin >> N >> M; for (int i = 0; i < M; i++) { int p, q, c; cin >> p >> q >> c; mp[P(p, 0)].push_back(PP(P(p, c), 1)); // 駅pで路線cに入る mp[P(p, c)].push_back(PP(P(q, c), 0)); // 路線cでp->q mp[P(q, c)].push_back(PP(P(q, 0), 0)); // 駅qで路線cから出る mp[P(q, 0)].push_back(PP(P(q, c), 1)); // 駅qで路線cに入る mp[P(q, c)].push_back(PP(P(p, c), 0)); // 路線cでq->p mp[P(p, c)].push_back(PP(P(p, 0), 0)); // 駅pで路線cから出る } dijkstra(P(1, 0)); int ans = cost[P(N, 0)] == 0 || cost[P(N, 0)] == inf ? -1 : cost[P(N, 0)]; cout << ans << "\n"; return 0; }
a.cc:16:16: error: stray '#' in program 16 | int N, M, inf=a#include <algorithm> | ^ a.cc:16:15: error: 'a' was not declared in this scope 16 | int N, M, inf=a#include <algorithm> | ^ a.cc:31:5: error: redefinition of 'int N' 31 | int N, M, inf=1e9; | ^ a.cc:16:5: note: 'int N' previously declared here 16 | int N, M, inf=a#include <algorithm> | ^ a.cc:31:8: error: redefinition of 'int M' 31 | int N, M, inf=1e9; | ^ a.cc:16:8: note: 'int M' previously declared here 16 | int N, M, inf=a#include <algorithm> | ^ a.cc:31:11: error: redefinition of 'int inf' 31 | int N, M, inf=1e9; | ^~~ a.cc:16:11: note: 'int inf' previously defined here 16 | int N, M, inf=a#include <algorithm> | ^~~ a.cc:82:22: error: conflicting declaration 'typedef struct std::pair<std::pair<int, int>, int> PP' 82 | typedef pair<P, int> PP; | ^~ a.cc:33:22: note: previous declaration as 'typedef struct std::pair<int, std::pair<int, int> > PP' 33 | typedef pair<int, P> PP; | ^~ a.cc:83:21: error: redefinition of 'std::map<std::pair<int, int>, std::vector<std::pair<int, std::pair<int, int> > > > mp' 83 | map <P, vector<PP>> mp; | ^~ a.cc:34:21: note: 'std::map<std::pair<int, int>, std::vector<std::pair<int, std::pair<int, int> > > > mp' previously declared here 34 | map <P, vector<PP>> mp; | ^~ a.cc:84:14: error: redefinition of 'std::map<std::pair<int, int>, int> cost' 84 | map <P, int> cost; | ^~~~ a.cc:35:14: note: 'std::map<std::pair<int, int>, int> cost' previously declared here 35 | map <P, int> cost; | ^~~~ a.cc:86:6: error: redefinition of 'void dijkstra(P)' 86 | void dijkstra(P start){ | ^~~~~~~~ a.cc:37:6: note: 'void dijkstra(P)' previously defined here 37 | void dijkstra(P start){ | ^~~~~~~~ a.cc: In function 'void dijkstra(P)': a.cc:96:35: error: conversion from 'int' to non-scalar type 'P' {aka 'std::pair<int, int>'} requested 96 | P next_station = next.first; | ~~~~~^~~~~ a.cc:97:26: error: cannot convert 'std::pair<int, int>' to 'int' in initialization 97 | int c = next.second; | ~~~~~^~~~~~ | | | std::pair<int, int> a.cc: At global scope: a.cc:106:5: error: redefinition of 'int main()' 106 | int main() { | ^~~~ a.cc:60:5: note: 'int main()' previously defined here 60 | int main() { | ^~~~ a.cc: In function 'int main()': a.cc:113:44: error: no matching function for call to 'std::pair<int, std::pair<int, int> >::pair(P, int)' 113 | mp[P(p, 0)].push_back(PP(P(p, c), 1)); // 駅pで路線cに入る | ^ In file included 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/bits/stl_pair.h:913:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<std::pair<int, int>, _U2>::value)), int, std::pair<int, int> >::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<std::pair<int, int>, _U2>::value)), int, std::pair<int, int> >::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 913 | explicit constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:913:28: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<std::pair<int, int>, _U2>::value)), int, std::pair<int, int> >::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<std::pair<int, int>, _U2>::value)), int, std::pair<int, int> >::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 902 | constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_pair.h:891:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 891 | explicit constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:891:28: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_pair.h:890:38: error: no type named 'type' in 'struct std::enable_if<false, bool>' 890 | bool>::type=false> | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:881:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 881 | constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:881:19: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_pair.h:880:38: error: no type named 'type' in 'struct std::enable_if<false, bool>' 880 | bool>::type=true> | ^~~~ /usr/include/c++/14/bits/stl_pair.h:869:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<std::pair<int, int>, _U2>, std::__not_<std::is_constructible<std::pair<int, int>, const _U1&> >, std::__not_<std::is_convertible<_U2, std::pair<int, int> > > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::__not_<std::is_convertible<_U2, _T2> > >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 869 | pair(__zero_as_null_pointer_constant, _U2&& __y, ...) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:869:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_pair.h:866:38: error: no type named 'type' in 'struct std::enable_if<false, bool>' 866 | bool> = false> | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:856:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<std::pair<int, int>, _U2>, std::__not_<std::is_constructible<std::pair<int, int>, const _U1&> >, std::is_convertible<_U2, std::pair<int, int> > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::is_convertible<_U2, _T2> >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = std::pair<int, int>]' 856 | pair(__zero_as_null_pointer_constant, _U2&& __y, ...) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:856:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_pair.h:853:38: error: no type named 'type' in 'struct std::enable_if<false, bool>' 853 | bool> = true> | ^~~~ /usr/include/c++/14/bits/stl_pair.h:843:9: note: candidate: 'template<class _U1, typename std::enable_if<std::__and_<std::__not_<std::is_reference<_Tp> >, std::is_pointer<std::pair<int, int> >, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::__not_<std::is_convertible<_U1, int> > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, __zero_as_null_pointer_constant, ...) [with typename std::enable_if<std::__and_<std::__not_<std::is_reference<_U1> >, std::is_pointer<_T2>, std::is_constructible<_T1, _U1>, std::__not_<std::is_constructible<_T1, const _U1&> >, s
s704113614
p04003
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define repe(i,n) rep(i,(n)+1) #define per(i,n) for(int i=(int)(n)-1;i>=0;i--) #define pere(i,n) rep(i,(n)+1) #define all(x) (x).begin(),(x).end() #define SP <<" "<< #define MOD 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 typedef long long LL; typedef long double LD; int main(){ int n,m; cin >> n >> m; vector<vector<pair<int,int>>> e(n); int p,q,c; for(int i=0;i<m;i++){ cin >> p >> q >> c; p--,q--; e[p].push_back({q,c}); e[q].push_back({p,c}); } deque<pair<int,pair<int,int>>> bfs; set<pair<int,int>> st; pair<int,pair<int,int>> now;a bfs.push_back({0,{-1,0}}); int ans=IINF; while(!bfs.empty()){ now=bfs.front(); bfs.pop_front(); if(now.first==n-1){ cout << now.second.second << endl; return 0; } for(auto &pa:e[now.first]){ if(st.find(pa)==st.end()){ st.insert(pa); if(pa.second==now.second.first){ bfs.push_front({pa.first,{pa.second,now.second.second}}); }else{ bfs.push_back({pa.first,{pa.second,now.second.second+1}}); } } } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:31: error: 'a' was not declared in this scope 30 | pair<int,pair<int,int>> now;a | ^ a.cc:31:27: error: expected primary-expression before ')' token 31 | bfs.push_back({0,{-1,0}}); | ^
s656455728
p04003
C++
#include<bits/stdc++.h> using namespace std; using int = int64_t; using P = pair<int, int>; const int INF = 1e9; template<typename T> class Dijk{ private: int n; vector<vector<pair<int, T>>> v; public: T INF; Dijk(const vector<vector<pair<int, T>>> &v, T INF){ this->n = v.size(); this->v = v; this->INF = INF; } vector<int> dijk(int start){ vector<int> d(n, INF); d[start] = 0; priority_queue<pair<int, T>, vector<pair<int, T>>, function<bool(pair<int, T>, pair<int, T>)>> q([&](pair<int, T> a, pair<int, T> b){return a.second > b.second;}); q.push(pair<int, T>(start, 0)); while(q.size()){ pair<int, T> now = q.top(); q.pop(); if(d[now.first] < now.second){ continue; } for(auto next : v[now.first]){ if(d[next.first] == INF || d[now.first] + next.second < d[next.first]){ d[next.first] = d[now.first] + next.second; q.push(pair<int, T>(next.first, d[now.first] + next.second)); } } } return d; } }; vector<vector<P>> edges; vector<P> idv = {P(-1, -1)}; int get_id(int n, int c){ auto ite = lower_bound(idv.begin(), idv.end(), P(n, c)); return ite - idv.begin(); } int main(){ int N, M; cin >> N >> M; vector<pair<P, int>> etmp; vector<vector<int>> company(N); for(int i = 0; i < M; i++){ int p, q, c; cin >> p >> q >> c; p--; q--; c--; company[p].push_back(c); company[q].push_back(c); etmp.push_back(make_pair(P(p, q), c)); } for(int i = 0; i < N; i++){ auto &v = company[i]; sort(v.begin(), v.end()); auto ite = unique(v.begin(), v.end()); v.erase(ite, v.end()); for(int c : v) idv.push_back(P(i, c)); } edges.resize(idv.size()); for(int c : company[0]){ int id = get_id(0, c); edges[0].push_back(P(id, 1)); edges[id].push_back(P(0, 1)); } for(int i = 0; i < N; i++){ for(int j = 0; j < company[i].size(); j++){ for(int k = j + 1; k < company[i].size(); k++){ int id1 = get_id(i, company[i][j]); int id2 = get_id(i, company[i][k]); edges[id1].push_back(P(id2, 1)); edges[id2].push_back(P(id1, 1)); } } } for(const auto &e : etmp){ int n1, n2; tie(n1, n2) = e.first; int id1 = get_id(n1, e.second); int id2 = get_id(n2, e.second); edges[id1].push_back(P(id2, 0)); edges[id2].push_back(P(id1, 0)); } Dijk<int> dijk(edges, INF); const auto dist = move(dijk.dijk(0)); int ans = INF; for(int c : company[N - 1]){ int id = get_id(N - 1, c); ans = min(ans, dist[id]); } if(ans == INF) ans = -1; cout << ans << endl; return 0; }
a.cc:3:7: error: expected nested-name-specifier before 'int' 3 | using int = int64_t; | ^~~
s967969255
p04003
C
//set many funcs template //Ver.20181228 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<time.h> #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 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 zt(int a,int b){return max(a,b)-min(a,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<=b;i++){r*=(a+1-i);r/=i;}return r;} int nHr(int a,int b){return nCr(a+b-1,b);} 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;} int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;} int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;} int sankaku(int x){return ((1+x)*x)/2;} 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 llzt(long long a,long long b){return llmax(a,b)-llmin(a,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<=b;i++){r*=(a+1-i);r/=i;}return r;} long long llnHr(long long a,long long b){return llnCr(a+b-1,b);} 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;} long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;} long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;} long long llsankaku(long long x){return ((1+x)*x)/2;} 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;} double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,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;} int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);} int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);} int chsortfncsj(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} int chsortfnckj(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} void shuffledget(int x[],int n){ srand(time(0)); int i,b[524288],p,c; for(i=0;i<n;i++){ b[i]=i; } for(i=n;i>=1;i--){ p=rand()%i; c=b[i-1];b[i-1]=b[p];b[p]=c; } for(i=0;i<n;i++){ scanf("%d",&x[b[i]]); } } int dx4[4]={1,-1,0,0}; int dy4[4]={0,0,1,-1}; int dx8[8]={-1,-1,-1,0,0,1,1,1}; int dy8[8]={-1,0,1,-1,1,-1,0,1}; int search(int x,int a[],int n){ int st=0,fi=n-1,te; while(st<=fi){ te=(st+fi)/2; if(a[te]<x){st=te+1;}else{fi=te-1;} } return st; } void prarr(int arr[],int n){ int i; for(i=0;i<n;i++){ if(i){printf(" ");} printf("%d",arr[i]); } printf("\n"); return; } typedef struct{ int val; int node; }sd; int sdsortfnc(const void *a,const void *b){ if(((sd*)a)->val < ((sd*)b)->val){return -1;} if(((sd*)a)->val > ((sd*)b)->val){return 1;} if(((sd*)a)->node < ((sd*)b)->node){return -1;} if(((sd*)a)->node > ((sd*)b)->node){return 1;} return 0; } long long sdsearch(sd x,sd a[],long long n){ long long st=0,fi=n-1,te; while(st<=fi){ te=(st+fi)/2; if(a[te].val<x.val){st=te+1;continue;} if(a[te].val>x.val){fi=te-1;continue;} if(a[te].node<x.node){st=te+1;continue;} if(a[te].node>x.node){fi=te-1;continue;} return te; } return -1; } //Dynamic Array typedef struct{ long long st; long long fi; long long kr; }rs; typedef struct{ long long st; long long kz; }mkj; int sortfnc(const void *a,const void *b){ if(((rs*)a)->st == ((rs*)b)->st){return 0;} if(((rs*)a)->st < ((rs*)b)->st){return -1;} return 1; } void makemkj(rs g[],mkj x[],long long n){ long long i,ms=0,nst=g[0].st; for(i=1;i<n;i++){ if(g[i].st!=g[i-1].st){ x[nst].kz=i-ms; x[nst].st=ms; nst=g[i].st;ms=i; } } x[nst].kz=n-ms; x[nst].st=ms; } //Heap and Priority_queue typedef struct{ long long node; long long cost; }data; data heap[2097152]; long long hsize=0; void resheap(){ hsize=0; long long i; heap[0].node=-1; heap[0].cost=-llinf; for(i=1;i<2097152;i++){ heap[i].node=-1; heap[i].cost=llinf; } } int swjud(data high,data low){ if(high.cost > low.cost){return 1;} return -1; } void pqpush(data x){ long long a,b; data m; hsize++; heap[hsize]=x; a=hsize; while(1){ b=a/2; if(swjud(heap[b],heap[a]) == 1){ m=heap[a];heap[a]=heap[b];heap[b]=m; } else{break;} a=b; } } data pqpop(){ long long a,b,c; data m,sw; m=heap[1]; heap[1]=heap[hsize]; heap[hsize].node=-1; heap[hsize].cost=llinf; hsize--; a=1; while(1){ b=a*2;c=a*2+1; if(swjud(heap[a],heap[b])==-1 && swjud(heap[a],heap[c])==-1){break;} if(swjud(heap[b],heap[c])==-1){ sw=heap[a];heap[a]=heap[b];heap[b]=sw; a=b; } else{ sw=heap[a];heap[a]=heap[c];heap[c]=sw; a=c; } } return m; } long long dijkstra(long long a,long long b,long long vc,rs g[],mkj x[]){ resheap(); long long i,j,dist[524288],nv; for(i=0;i<=vc;i++){ dist[i]=llinf; } data pd,od; pd.node=a; pd.cost=0; pqpush(pd); while(hsize>0){ od=pqpop(); nv=od.node; if(nv==b){return od.cost;} if(dist[nv]!=llinf){continue;} dist[nv]=od.cost; for(i=x[nv].st;i<x[nv].st+x[nv].kz;i++){ if(dist[g[i].fi]!=llinf){continue;} pd.node=g[i].fi; pd.cost=od.cost+g[i].kr; pqpush(pd); } } return llinf; } int main(void){ long long i,j,n,m,k,h,w,r=0,l,t,cnt=0,p,q; long long a[524288],b[524288],c[524288]; rs g[2097152]; mkj x[524288]; sd dat[524288],wa; scanf("%lld%lld",&n,&m); for(i=0;i<m;i++){ scanf("%lld%lld%lld",&a[i],&b[i],&c[i]); dat[2*i].val=a[i]; dat[2*i].node=c[i]; dat[2*i+1].val=b[i]; dat[2*i+1].node=c[i]; } qsort(dat,2*m,sizeof(dat[0]),sdsortfnc); w=0; dat[2*m].val=inf; for(i=0;i<2*m;i++){ if(dat[i].val != dat[i+1].val || dat[i].node != dat[i+1].node){ dat[w]=dat[i]; w++; } } for(i=1;i<=n;i++){ dat[w+i-1].val=i; dat[w+i-1].node=-1; } for(i=0;i<w;i++){ g[cnt].st=i; g[cnt].fi=w+dat[i].val-1; g[cnt].kr=1; cnt++; g[cnt].fi=i; g[cnt].st=w+dat[i].val-1; g[cnt].kr=0; cnt++; } for(i=0;i<2*m;i++){ wa.node=a[i]; wa.cost=c[i]; p=sdsearch(wa,dat,w); wa.node=b[i]; wa.cost=c[i]; q=sdsearch(wa,dat,w); g[cnt].st=p; g[cnt].fi=q; g[cnt].kr=0; cnt++; g[cnt].fi=p; g[cnt].st=q; g[cnt].kr=0; cnt++; } qsort(g,cnt,sizeof(g[0]),sortfnc); makemkj(g,x,cnt); printf("%lld\n",dijkstra(w,w+n-1,524288,g,x)); return 0; }
main.c:16:5: warning: conflicting types for built-in function 'round'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 16 | int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~ main.c:8:1: note: 'round' is declared in header '<math.h>' 7 | #include<time.h> +++ |+#include <math.h> 8 | #define inf 1072114514 main.c:17:5: warning: conflicting types for built-in function 'ceil'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 17 | int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;} | ^~~~ main.c:17:5: note: 'ceil' is declared in header '<math.h>' main.c:23:5: warning: conflicting types for built-in function 'pow'; expected 'double(double, double)' [-Wbuiltin-declaration-mismatch] 23 | int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} | ^~~ main.c:23:5: note: 'pow' is declared in header '<math.h>' main.c:30:11: warning: conflicting types for built-in function 'llround'; expected 'long long int(double)' [-Wbuiltin-declaration-mismatch] 30 | long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~~~ main.c:30:11: note: 'llround' is declared in header '<math.h>' main.c: In function 'main': main.c:284:9: error: 'sd' has no member named 'cost' 284 | wa.cost=c[i]; | ^ main.c:287:9: error: 'sd' has no member named 'cost' 287 | wa.cost=c[i]; | ^
s876943665
p04003
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 ll n, cnt, ans, a, b, c, dist[ohara], tmp, tmpp, m, h, w, x, y, sum, pos, k, vertex[ohara],id[ohara]; 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 { ll from, to; }; vector<edge> g[ohara]; vector<edge> di_g[ohara]; unordered_map<ll, ll> used; map<pair<ll, ll>, ll> hen; //-------------------------↓↓↓↓↓↓------------------------ struct UnionFind { std::vector<int> data; UnionFind(int n) { data.assign(n, -1); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (data[x] > data[y]) std::swap(x, y); data[x] += data[y]; data[y] = x; } int find(int k) { if (data[k] < 0) return k; return data[k] = find(data[k]); } bool same(int x, int y) { return find(x) == find(y); } }; void dijkstra(ll s) { priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que; fill(dist, dist 2*ohara, LINF); dist[s] = 0; que.push({0LL, s}); while (!que.empty()) { pair<ll, ll> p = que.top(); que.pop(); ll v = p.second; if (dist[v] < p.first) continue; rep(i, Size(di_g[v])) { edge e = di_g[v][i]; if (dist[e.from] > dist[v] + e.to) { dist[e.from] = dist[v] + e.to; que.push({dist[e.from], e.from}); } } } } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; UnionFind uf(n); rep(i, m) { cin >> a >> b >> c; a--; b--; g[c].push_back({a, b}); } tmp = n; rrep(com, 1, 1000001) { if (Size(g[com]) == 0) continue; unordered_map<ll, ll> syutugen; unordered_map<ll, ll> aluse; rep(j, Size(g[com])) { uf.unite(g[com][j].from, g[com][j].to); vertex[g[com][j].from]=vertex[g[com][j].to]=-1; } rep(j, Size(g[com])) { ll gr; gr = uf.find((g[com][j].from)); if (vertex[gr]==-1){ { vertex[gr] = tmp++; } if (aluse[g[com][j].from] == 0) { if (hen[{g[com][j].from, vertex[gr]}] == 0) { di_g[g[com][j].from].push_back({vertex[gr], 1LL}); } if (hen[{vertex[gr], g[com][j].from}] == 0) { di_g[vertex[gr]].push_back({g[com][j].from, 1LL}); } //cout << g[com][j].from << " " << vertex[gr] << "\n"; hen[{g[com][j].from, vertex[gr]}] = 1; hen[{vertex[gr], g[com][j].from}] = 1; aluse[g[com][j].from] = 1; } // RE; //Cout(g[com][j].to); gr = uf.find((g[com][j].to)); if (vertex[gr] == -1) { vertex[gr] = tmp++; } if (aluse[g[com][j].to] == 0) { if (hen[{g[com][j].to, vertex[gr]}] == 0) { di_g[g[com][j].to].push_back({vertex[gr], 1LL}); } if (hen[{vertex[gr], g[com][j].to}] == 0) { di_g[vertex[gr]].push_back({g[com][j].to, 1LL}); } hen[{g[com][j].to, vertex[gr]}] = 1; hen[{vertex[gr], g[com][j].to}] = 1; //cout << g[com][j].to << " " << vertex[gr] << "\n"; //aluse[g[com][j].to] = 1; } } } } //rep(i,n)Cout(vertex[uf.find(i)]); dijkstra(0LL); //rep(i, n * 2 + 1) Cout(dist[i]); if (uf.find(0LL) == uf.find(n - 1)) { Cout(dist[n - 1] / 2); } else { Cout(-1); } return 0; }
a.cc: In function 'void dijkstra(ll)': a.cc:71:20: error: expected ')' before numeric constant 71 | fill(dist, dist 2*ohara, LINF); | ~ ^~ | )
s202552129
p04003
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 ll n, cnt, ans, a, b, c, dist[ohara], tmp, tmpp, m, h, w, x, y, sum, pos, k, vertex[ohara],id[ohara]; 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 { ll from, to; }; vector<edge> g[ohara]; vector<edge> di_g[ohara]; unordered_map<ll, ll> used; map<pair<ll, ll>, ll> hen; //-------------------------↓↓↓↓↓↓------------------------ struct UnionFind { std::vector<int> data; UnionFind(int n) { data.assign(n, -1); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (data[x] > data[y]) std::swap(x, y); data[x] += data[y]; data[y] = x; } int find(int k) { if (data[k] < 0) return k; return data[k] = find(data[k]); } bool same(int x, int y) { return find(x) == find(y); } }; void dijkstra(ll s) { priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que; fill(dist, dist + tmp, LINF); dist[s] = 0; que.push({0LL, s}); while (!que.empty()) { pair<ll, ll> p = que.top(); que.pop(); ll v = p.second; if (dist[v] < p.first) continue; rep(i, Size(di_g[v])) { edge e = di_g[v][i]; if (dist[e.from] > dist[v] + e.to) { dist[e.from] = dist[v] + e.to; que.push({dist[e.from], e.from}); } } } } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; UnionFind uf(n); rep(i, m) { cin >> a >> b >> c; a--; b--; g[c].push_back({a, b}); } tmp = n; rrep(com, 1, 1000001) { if (Size(g[com]) == 0) continue; unordered_map<ll, ll> syutugen; unordered_map<ll, ll> aluse; rep(j, Size(g[com])) { uf.unite(g[com][j].from, g[com][j].to); vertex[g[com][j].from]=vertex[g[com][j].to]=-1; } rep(j, Size(g[com])) { ll gr; gr = uf.find((g[com][j].from)); if (vertex[gr]==-1){ { vertex[gr] = tmp++; } if (aluse[g[com][j].from] == 0) { if (hen[{g[com][j].from, vertex[gr]}] == 0) { di_g[g[com][j].from].push_back({vertex[gr], 1LL}); } if (hen[{vertex[gr], g[com][j].from}] == 0) { di_g[vertex[gr]].push_back({g[com][j].from, 1LL}); } //cout << g[com][j].from << " " << vertex[gr] << "\n"; hen[{g[com][j].from, vertex[gr]}] = 1; hen[{vertex[gr], g[com][j].from}] = 1; aluse[g[com][j].from] = 1; } // RE; //Cout(g[com][j].to); gr = uf.find((g[com][j].to)); if (vertex[gr] == -1) { vertex[gr] = tmp++; } if (aluse[g[com][j].to] == 0) { if (hen[{g[com][j].to, vertex[gr]}] == 0) { di_g[g[com][j].to].push_back({vertex[gr], 1LL}); } if (hen[{vertex[gr], g[com][j].to}] == 0) { di_g[vertex[gr]].push_back({g[com][j].to, 1LL}); } hen[{g[com][j].to, vertex[gr]}] = 1; hen[{vertex[gr], g[com][j].to}] = 1; //cout << g[com][j].to << " " << vertex[gr] << "\n"; //aluse[g[com][j].to] = 1; } } } //rep(i,n)Cout(vertex[uf.find(i)]); dijkstra(0LL); //rep(i, n * 2 + 1) Cout(dist[i]); if (uf.find(0LL) == uf.find(n - 1)) { Cout(dist[n - 1] / 2); } else { Cout(-1); } return 0; }
a.cc: In function 'int main()': a.cc:179:2: error: expected '}' at end of input 179 | } | ^ a.cc:94:1: note: to match this '{' 94 | { | ^
s030685550
p04003
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define vi vector<ll> #define vvi vector<vi> #define substr(s,f,t) (s.substr(f-1,t-f+1)) #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; using namespace std; struct Grid{ll x,y,t;}; struct Edge{ll to,cost;}; map<pair<ll,ll>,ll>MP; struct Graph{vector<vector<Edge>>E;int V; const ll Inf = llINF;const int MAX_V=2211111;vector<ll>d; Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;} void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;} void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});E[to].pb({from,cost});} void dijkstra(ll s){ priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >que; init(); d[s] = 0; que.push(pair<ll,ll>(0,s)); while(!que.empty()){ pair<ll,ll> p=que.top();que.pop(); ll v = p.second; if(d[v]<p.first)continue; for(int j=0;j<E[v].size();j++){ Edge t = E[v][j]; if(d[t.to]>d[v]+t.cost){ d[t.to]=d[v]+t.cost; que.push(pair<ll,ll>(d[t.to],t.to)); } } } } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n,m;cin>>n>>m; int cnt=1; Graph G(2211110); for(int i=0;i<m;i++){ ll a,b,c;cin>>a>>b>>c; if(MP[mp(a,-1)]==0)MP[mp(a,-1)]=cnt++; if(MP[mp(b,-1)]==0)MP[mp(b,-1)]=cnt++; if(MP[mp(a,c)]==0)MP[mp(a,c)]=cnt++; if(MP[mp(b,c)]==0)MP[mp(b,c)]=cnt++; G.add_edge(MP[mp(a,-1)],MP[mp(a,c)],1); G.add_edge(MP[mp(b,-1)],MP[mp(b,c)],1); G.add_edge(MP[mp(a,c)],MP[mp(b,c)],0); } if(MP[(1,-1)]==0){ cout<<-1<<endl; return 0; } G.dijkstra(MP[mp(1,-1)]); if(G.d[MP[mp(n,-1)]]==llINF)cout<<-1<<endl; else cout<<G.d[MP[mp(n,-1)]]/2<<endl; return 0; }
a.cc: In function 'int main()': a.cc:60:8: error: no match for 'operator[]' (operand types are 'std::map<std::pair<long long int, long long int>, long long int>' and 'int') 60 | if(MP[(1,-1)]==0){ | ^ In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; mapped_type = long long int; key_type = std::pair<long long int, long long int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<long long int, long long int>, long long int>::key_type&' {aka 'const std::pair<long long int, long long int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; mapped_type = long long int; key_type = std::pair<long long int, long long int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<long long int, long long int>, long long int>::key_type&&' {aka 'std::pair<long long int, long long int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s295611008
p04003
C++
#include <bits/stdc++.h> #define typeof(x) __typeof__(x) #define int long long int #define double long double #define mod(x) ((x % MOD) + MOD) % MOD #define REP(i,a,b) for(int i=(a);i<(b);++i) #define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i) #define ALL(c) (c).begin(),(c).end() #define RALL(c) (c).rbegin(),(c).rend() #define SZ(c) (int)((c).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin()) #define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin()) #define COUNT(c,x) (UB(c,x)-LB(c,x)) #define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end()); #define COPY(c1,c2) copy(ALL(c1),(c2).begin()) #define EXIST(s,e) (s).find(e)!=(s).end() #define PB push_back #define MP make_pair #define vec vector #define DUMP(x) cerr << #x << " = " << (x) << endl; #define NL cerr << endl; using namespace std; typedef pair<int,pair<int,int>> P; struct edge { int from; pair<int,int> to; int cost; }; bool operator< (const edge &edge1, const edge &edge2){ return edge1.cost < edge2.cost; }; const int INF = 1e18; const int MOD = 1e9+7; template<typename T> ostream& operator << (ostream& s, const vector<T>& v) { s << "["; for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; } s << "]"; return s; } template<typename T> ostream& operator << (ostream& s, const set<T>& se) { s << "{"; for (auto i = se.begin(); i != se.end(); ++i) { s << *i; if (next(i) != se.end()) s << ", "; } s << "}"; return s; } template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) { s << "(" << p.first << "," << p.second << ")"; return s; } template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) { s << "{"; for (auto i = m.begin(); i != m.end(); ++i) { s << i->first << ":" << i->second; if (next(i) != m.end()) s << ", "; } s << "}"; return s; } ostream& operator << (ostream& s, const edge& e) { s << "(" << e.from << "->" << e.to << ": " << e.cost << ")"; return s; } void add_edge0(vec<map<int,vec<edge>>>& G, int u, int v, int com) { G[u][com].PB((edge){ u, MP(v, com), 0 }); G[v][com].PB((edge){ v, MP(u, com), 0 }); } void add_edge1(vec<map<int,vec<edge>>>& G, int u, int com) { G[u][com].PB((edge){ u, MP(u, -1), 0 }); G[u][-1].PB((edge){ u, MP(u, com), 1 }); } void dijkstra(vec<map<int,vec<edge>>>& G, map<pair<int,int>,int>& d, int s, int scom) { priority_queue<P, vector<P>, greater<P> > que; EACH(i, d) { i->second = INF; } d[MP(s,scom)] = 0; que.push(MP(0, MP(s,scom))); while(!que.empty()) { int temp_cost = que.top().first; pair<int,int> from = que.top().second; que.pop(); if (d[from] < temp_cost) continue; for (int i = 0; i < G[from.first][from.second].size(); i++) { edge e = G[from.first][from.second][i]; if (d[e.to] > d[from] + e.cost) { d[e.to] = d[from] + e.cost; que.push(MP(d[e.to], e.to)); } } } } signed main() { int N, M; cin >> N >> M; vec<int> p(M), q(M), c(M); REP(i, 0, M) { cin >> p[i] >> q[i] >> c[i]; p[i]--; q[i]--; c[i]--; } vec<map<int,vec<edge>>> G(N); REP(i, 0, M) { add_edge0(G, p[i], q[i], c[i]); } vec<set<int>> coms(N); REP(i, 0, M) { coms[p[i]].insert(c[i]); coms[q[i]].insert(c[i]); } REP(i, 0, N) { EACH(c, coms[i]) { add_edge1(G, i, c); } } map<pair<int,int>,int> d; REP(i, 0, N) { EACH(j, coms[i]) { d[MP(i,*j)] = INF; } } dijkstra(G, d, 0, -1); if (d[MP(N-1,-2)] == INF) { cout << -1 << endl; } else { cout << d[MP(N-1,-1)] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:127:26: error: cannot convert 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} to 'long long int' 127 | add_edge1(G, i, c); | ^ | | | std::set<long long int>::iterator {aka std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator} a.cc:77:55: note: initializing argument 3 of 'void add_edge1(std::vector<std::map<long long int, std::vector<edge> > >&, long long int, long long int)' 77 | void add_edge1(vec<map<int,vec<edge>>>& G, int u, int com) { | ^
s564035359
p04003
C++
#include<iostream> #include<vector> #include<algorithm> #include<utility> #include<string> #include<cmath> #include<cstring> #include<queue> #include<map> #include<climits> #include<queue> #include<set> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) using namespace std; typedef pair<int, int> P; typedef long long int ll; typedef pair<ll,ll> LLP; int dx[4] = {1,0,0,-1}; int dy[4] = {0,1,-1,0}; #define INF 1000000007 #define MOD 1000000007 #define ARRAY_MAX 100005 typedef struct edge{ pair<int,int> to;//今いる位置、会社 int cost;//移動にかかるコスト }EDGE; int n,m; map<P,vector<EDGE> > G; set<P> used; int bfs(){ deque<EDGE> deq; deq.push_back(EDGE{P(0,-1),0}); int ans = -1; while(!deq.empty()){ EDGE es = deq.front(); deq.pop_front(); if(used.find(es.to) != used.end()){ //もう使ったので調べない continue; } used.insert(es.to); if(es.to == P(n-1,-1)){ //目的地に着いた //つまり、駅nの改札を出たところなら ans = es.cost; break; } for(auto itr:G[es.to]){ //次の駅の候補を調べる if(used.find(itr.to) != used.end()){ //次の駅がすでに調べられているなら調べない continue; } if(itr.cost == 0){ deq.push_front({itr.to,es.cost}); }else{ deq.push_back({itr.to,es.cost+1}); } } } return ans; } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin >> n >> m; REP(i,m){ int p,q,c; cin >> p >> q >> c; p--; q--; //同じ会社の間にコスト0の辺を張る G[P(p,c)].push_back((EDGE){P(q,c),0}); G[P(q,c)].push_back((EDGE){P(p,c),0}); //駅番号-1は駅から改札を出ることを表す,コスト0の辺を張る G[P(p,c)].push_back((EDGE){P(p,-1),0}); G[P(q,c)].push_back((EDGE){P(q,-1),0}); //改札を出て別の会社の駅に入る時にコスト1かかるとする,コスト1の辺を張る //途中で別の会社を使って再びもとの会社を使う時にもコストはかかる G[P(p,-1)].push_back((EDGE){P(q,c),1}); G[P(q,-1)].push_back((EDGE){P(p,c),1}); } int ans = bfs(); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:84:22: error: 'setprecision' was not declared in this scope 84 | cout << fixed << setprecision(10); | ^~~~~~~~~~~~ a.cc:13:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 12 | #include<set> +++ |+#include <iomanip> 13 |
s445872449
p04003
C++
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; const int Maxn = 1e5; const int INF = 0x3f3f3f3f; struct Edge { int to,cost; Edge(int a,int b){to=a,cost=b;} }; vector<Edge> G[8*Maxn+5]; void AddEdge(int u,int v,int w) { G[u].push_back(Edge(v,w)); G[v].push_back(Edge(u,w)); } int dist[8*Maxn+5]; bool vis[8*Maxn+5]; void SPFA(int s) { memset(dist,0x3f,sizeof dist); memset(vis,false,sizeof vis); queue<int> q; q.push(s); vis[s]=true,dist[s]=0; while(!q.empty()) { int u=q.front(); q.pop();vis[u]=false; for(int i=0;i<G[u].size();i++) { int v=G[u][i].to,w=G[u][i].cost; if(dist[v]>dist[u]+w) { dist[v]=dist[u]+w; if(!vis[v]) { vis[v]=true; q.push(v); } } } } } map<pair<int,int>,int> P; int cnt; int Getid(int u,int c) { if(P.find(make_pair(u,c))!=P.end()) return P[make_pair(u,c)]; return P[make_pair(u,c)]=++cnt; } int N,M; int main() { scanf("%d %d",&N,&M); cnt=N; for(int i=1;i<=M;i++) { int u,v,c; scanf("%d %d %d",&u,&v,&c); int t1=Getid(u,c); int t2=Getid(v,c); AddEdge(t1,t2,0); AddEdge(u,t1,1); AddEdge(v,t2,1); } SPFA(1); if(dist[N]==INF)puts("-1"); else printf("%d\n",dist[N]/2); return 0; }
a.cc:11:1: error: 'vector' does not name a type 11 | vector<Edge> G[8*Maxn+5]; | ^~~~~~ a.cc: In function 'void AddEdge(int, int, int)': a.cc:13:5: error: 'G' was not declared in this scope 13 | G[u].push_back(Edge(v,w)); | ^ a.cc: In function 'void SPFA(int)': a.cc:22:5: error: 'queue' was not declared in this scope 22 | queue<int> q; | ^~~~~ a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' 3 | #include <cstring> +++ |+#include <queue> 4 | using namespace std; a.cc:22:11: error: expected primary-expression before 'int' 22 | queue<int> q; | ^~~ a.cc:24:5: error: 'q' was not declared in this scope 24 | q.push(s); | ^ a.cc:31:23: error: 'G' was not declared in this scope 31 | for(int i=0;i<G[u].size();i++) { | ^ a.cc:33:32: error: 'w' was not declared in this scope 33 | if(dist[v]>dist[u]+w) { | ^ a.cc: At global scope: a.cc:44:1: error: 'map' does not name a type 44 | map<pair<int,int>,int> P; | ^~~ a.cc: In function 'int Getid(int, int)': a.cc:47:8: error: 'P' was not declared in this scope 47 | if(P.find(make_pair(u,c))!=P.end()) | ^ a.cc:49:12: error: 'P' was not declared in this scope 49 | return P[make_pair(u,c)]=++cnt; | ^
s377859235
p04003
C++
#include<bits/stdc++.h> #define MX 1000005 #define INF 1000000005 using namespace std; typedef long long int ll; typedef pair <int,int> P; vector<int> sad[12312313] struct UF { int par[MX],rank[MX]; void init(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } void rem(int i) { par[i]=i; rank[i]=0; } 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(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); } }; UF uf; vector <int> vec[MX]; vector <P> query[MX]; int id[MX]; bool use[MX]; int dp[MX]; int main() { int n,m; scanf("%d %d",&n,&m); for(int i=0;i<m;i++) { int p,q,c; scanf("%d %d %d",&p,&q,&c);p--,q--,c--; query[c].push_back(P(p,q)); } int sz=n; for(int i=0;i<MX;i++) { if(query[i].empty()) continue; for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.rem(p.first); uf.rem(p.second); id[p.first]=id[p.second]=-1; use[p.first]=use[p.second]=false; } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.unite(p.first,p.second); } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; use[p.first]=true; int r=uf.find(p.first); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.first); vec[p.first].push_back(id[r]); vec[id[r]].push_back(p.first); use[p.second]=true; r=uf.find(p.second); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.second); vec[p.second].push_back(id[r]); vec[id[r]].push_back(p.second); } } queue <int> que; que.push(0); memset(dp,-1,sizeof(dp)); dp[0]=0; while(!que.empty()) { int v=que.front();que.pop(); for(int i=0;i<vec[v].size();i++) { int to=vec[v][i]; if(dp[to]==-1) { dp[to]=dp[v]+1; que.push(to); } } } if(dp[n-1]==-1) puts("-1"); else printf("%d\n",dp[n-1]/2); return 0; }
a.cc:8:1: error: expected initializer before 'struct' 8 | struct UF | ^~~~~~ a.cc:50:1: error: 'UF' does not name a type 50 | UF uf; | ^~ a.cc: In function 'int main()': a.cc:74:25: error: 'uf' was not declared in this scope 74 | uf.rem(p.first); | ^~ a.cc:82:25: error: 'uf' was not declared in this scope 82 | uf.unite(p.first,p.second); | ^~ a.cc:88:39: error: 'uf' was not declared in this scope 88 | int r=uf.find(p.first); | ^~
s671501367
p04003
C++
#include<bits/stdc++.h> #define MX 1000005 #define INF 1000000005 using namespace std; typedef long long int ll; typedef pair <int,int> P; struct UF { int par[MX],rank[MX]; void init(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } void rem(int i) { par[i]=i; rank[i]=0; } 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(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); } }; UF uf; vector <int> vec[MX]; vector <P> query[MX]; int id[MX]; bool use[MX]; int dp[MX]; int main() { int n,m; scanf("%d %d",&n,&m); for(int i=0;i<m;i++) { int p,q,c; scanf("%d %d %d",&p,&q,&c);p--,q--,c--; query[c].push_back(P(p,q)); } int sz=n; for(int i=0;i<MX;i++) { if(query[i].empty()) continue; for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.rem(p.first); uf.rem(p.second); id[p.first]=id[p.second]=-1; use[p.first]=use[p.second]=false; } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.unite(p.first,p.second); } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; use[p.first]=true; int r=uf.find(p.first); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.first); vec[p.first].push_back(id[r]); vec[id[r]].push_back(p.first); use[p.second]=true; int r=uf.find(p.second); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.second); vec[p.second].push_back(id[r]); vec[id[r]].push_back(p.second); } } queue <int> que; que.push(0); memset(dp,-1,sizeof(dp)); dp[0]=0; while(!que.empty()) { int v=que.front();que.pop(); for(int i=0;i<vec[v].size();i++) { int to=vec[v][i]; if(dp[to]==-1) { dp[to]=dp[v]+1; que.push(to); } } } if(dp[n-1]==-1) puts("-1"); else printf("%d\n",dp[n-1]/2); return 0; }
a.cc: In function 'int main()': a.cc:94:37: error: redeclaration of 'int r' 94 | int r=uf.find(p.second); | ^ a.cc:88:37: note: 'int r' previously declared here 88 | int r=uf.find(p.first); | ^
s361219349
p04003
C++
#include<bits/stdc++.h> #define MX 1000005 #define INF 1000000005 using namespace std; typedef long long int ll; typedef pair <int,int> P; struct UF { int par[MX],rank[MX]; void init(int n) { for(int i=0;i<n;i++) { par[i]=i; rank[i]=0; } } void rem(int i) { par[i]=i; rank[i]=0; } 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(rank[x]<rank[y]) { par[x]=y; } else { par[y]=x; if(rank[x]==rank[y]) rank[x]++; } } bool same(int x,int y) { cout<<sum(par,par+10,0); return find(x)==find(y); } }; UF uf; vector <int> vec[MX]; vector <P> query[MX]; int id[MX]; bool use[MX]; int dp[MX]; int main() { int n,m; scanf("%d %d",&n,&m); for(int i=0;i<m;i++) { int p,q,c; scanf("%d %d %d",&p,&q,&c);p--,q--,c--; query[c].push_back(P(p,q)); } int sz=n; for(int i=0;i<MX;i++) { if(query[i].empty()) continue; for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.rem(p.first); uf.rem(p.second); id[p.first]=id[p.second]=-1; use[p.first]=use[p.second]=false; } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; uf.unite(p.first,p.second); } for(int j=0;j<query[i].size();j++) { P p=query[i][j]; if(!use[p.first]) { use[p.first]=true; int r=uf.find(p.first); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.first); vec[p.first].push_back(id[r]); vec[id[r]].push_back(p.first); } if(!use[p.second]) { use[p.second]=true; int r=uf.find(p.second); if(id[r]==-1) id[r]=sz++; //printf("%d %d: %d\n",r,id[r],p.second); vec[p.second].push_back(id[r]); vec[id[r]].push_back(p.second); } } } queue <int> que; que.push(0); memset(dp,-1,sizeof(dp)); dp[0]=0; while(!que.empty()) { int v=que.front();que.pop(); for(int i=0;i<vec[v].size();i++) { int to=vec[v][i]; if(dp[to]==-1) { dp[to]=dp[v]+1; que.push(to); } } } if(dp[n-1]==-1) puts("-1"); else printf("%d\n",dp[n-1]/2); return 0; }
a.cc: In member function 'bool UF::same(int, int)': a.cc:47:23: error: 'sum' was not declared in this scope 47 | cout<<sum(par,par+10,0); | ^~~
s247183951
p04003
C++
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; struct Node{ int to, dis; Node(int _to, int _dis){to = _to, dis = _dis;} bool operator < (const Node &A) const{ return dis > A.dis; } }; vector <Node> g[100010]; vector <Node> from[200010]; int n, m, tot; int dis[200010][2]; priority_queue <Node> q; void Dij(int s, int p){ for (int i = 1; i < tot; i++){ dis[i][p] = INF; } dis[s][p] = 1; q.push(Node(s, 1)); while (!q.empty()){ Node t = q.top(); q.pop(); int u = t.to; if (dis[u][p] < t.dis) continue; for (int i = 0; i < from[u].size(); i++){ int v = from[u][i].to; if (dis[v][p] > dis[u][p] + from[u][i].dis){ dis[v][p] = dis[u][p] + from[u][i].dis; q.push(Node(v, dis[v][p])); } } } } map <int, bool> hash[100010]; void make_new(int x, int c, int num){ if (hash[x][c]) return ; // cout << " " << x << " " << c << " " << num << endl; hash[x][c] = 1; from[x].push_back(Node(num, 0)); for (int i = 0; i < g[x].size(); i++){ if (g[x][i].dis != c) continue; int v = g[x][i].to; make_new(v, c, num); } } int change(int x, int c, int t){ if (hash[x][c]) return 0; make_new(x, c, tot++); return 1; } int main(){ scanf("%d%d", &n, &m); for (int i = 0; i < m; i++){ int u, v, c; scanf("%d%d%d", &u, &v, &c); g[u].push_back(Node(v, c)); g[v].push_back(Node(u, c)); } tot = n + 1; for (int i = 1; i <= n; i++){ // cout << i << endl; for (int j = 0; j < g[i].size(); j++){ // cout << " " << j << endl; change(i, g[i][j].dis, tot); } } for (int i = 1; i <= n; i++){ for (int j = 0; j < from[i].size(); j++){ int u = from[i][j].to; for (int k = j + 1; k < from[i].size(); k++){ int v = from[i][k].to; from[u].push_back(Node(v, 1)); from[v].push_back(Node(u, 1)); } } } Dij(1, 0); Dij(n, 1); int ans = INF; for (int i = n + 1; i < tot; i++){ ans = min(ans, dis[i][0] + dis[i][1]); } printf("%d\n", ans == INF ? -1 : ans - 1); return 0; }
a.cc: In function 'void make_new(int, int, int)': a.cc:43:13: error: reference to 'hash' is ambiguous 43 | if (hash[x][c]) return ; | ^~~~ In file included from /usr/include/c++/14/string_view:50, 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, from a.cc:1: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:40:17: note: 'std::map<int, bool> hash [100010]' 40 | map <int, bool> hash[100010]; | ^~~~ a.cc:45:9: error: reference to 'hash' is ambiguous 45 | hash[x][c] = 1; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:40:17: note: 'std::map<int, bool> hash [100010]' 40 | map <int, bool> hash[100010]; | ^~~~ a.cc: In function 'int change(int, int, int)': a.cc:55:13: error: reference to 'hash' is ambiguous 55 | if (hash[x][c]) return 0; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:40:17: note: 'std::map<int, bool> hash [100010]' 40 | map <int, bool> hash[100010]; | ^~~~
s700533038
p04003
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back #define edge(v,a,b) v[a].pb(b);v[b].pb(a); ll MOD=1e9+7; #define INF 2*1e9 #define N 600010 #define MAX_V 900010 using namespace std; //ダイクストラ法、負の閉路ダメ struct edge{int to,cost;}; int V; vector<edge> G[MAX_V]; int d[MAX_V]; void dijkstra(int s){ priority_queue<pii> que; fill(d,d+MAX_V,INF); d[s]=0; que.push(pii(0,s)); while(!que.empty()){ pii p=que.top();que.pop(); int v=p.second; if(d[v]<p.first)continue; rep(i,G[v].size()){ edge e=G[v][i]; if(d[e.to]>d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push({d[e.to],e.to}); } } } } main(){ int mm;cin>>V>>mm; V++; unordered_map<pii,int> m; int temp=3; m[{1,0}]=1;m[{V-1,0}]=2; rep(i,mm){ int p,q,c;cin>>p>>q>>c; int a=m[{p,c}],b=m[{q,c}],aa=m[{p,0}],bb=m[{q,0}]; if(aa==0){ aa=m[{p,0}]=temp;temp++; } if(bb==0){ bb=m[{q,0}]=temp;temp++; } if(a==0){ a=m[{p,c}]=temp;temp++; G[aa].pb({a,1});G[a].pb({aa,1}); } if(b==0){ b=m[{q,c}]=temp;temp++; G[bb].pb({b,1});G[b].pb({bb,1}); } G[a].pb({b,0});G[b].pb({a,0}); } dijkstra(1); cout<<(d[2]==INF?-1:d[2]/2); }
a.cc:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 39 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:42:28: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 42 | unordered_map<pii,int> m; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtab
s210581878
p04003
C++
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize(3) #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC target("sse3","sse2","sse") #pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3") #pragma GCC target("f16c") #pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector") #pragma GCC diagnostic error "-fwhole-program" #pragma GCC diagnostic error "-fcse-skip-blocks" #pragma GCC diagnostic error "-funsafe-loop-optimizations" #pragma GCC diagnostic error "-std=c++14" #include "bits/stdc++.h" //#include "ext/pb_ds/tree_policy.hpp" //#include "ext/pb_ds/assoc_container.hpp" #define PB push_back #define PF push_front #define LB lower_bound #define UB upper_bound #define fr(x) freopen(x,"r",stdin) #define fw(x) freopen(x,"w",stdout) #define iout(x) printf("%d\n",x) #define lout(x) printf("%lld\n",x) #define REP(x,l,u) for(ll x = l;x<u;x++) #define RREP(x,l,u) for(ll x = l;x>=u;x--) #define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end()) #define mst(x,a) memset(x,a,sizeof(x)) #define all(a) a.begin(),a.end() #define PII pair<int,int> #define PLL pair<ll,ll> #define MP make_pair #define sqr(x) ((x)*(x)) #define lowbit(x) (x&(-x)) #define lson (ind<<1) #define rson (ind<<1|1) #define se second #define fi first #define dbg(x) cerr<<#x<<" = "<<(x)<<endl; #define sz(x) ((int)x.size()) #define EX0 exit(0); typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; using namespace std; typedef vector<ll> VLL; typedef vector<int> VI; const int block_size = 320; typedef complex<ll> point; const ll mod = 1e9+7; const ll inf = 1e9+7; const ld eps = 1e-9; const db PI = atan(1)*4; template<typename T> inline int sign(const T&a) { if(a<0)return -1; if(a>0)return 1; return 0; } template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;} template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;} template<typename T> inline void in(T &x) { x = 0; T f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } x *= f; } ll twop(int x) { return 1LL<<x; } template<typename A,typename B > inline void in(A&x,B&y) { in(x); in(y); } template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) { in(x); in(y); in(z); } template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) { in(x); in(y); in(z); in(d); } ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);} namespace SOLVE { void main(){ } } map<int, vector<int>>ed[1000010]; vector<PII>adj[100010]; int n,m; int dis[100010]; set<PII>vis; int original; void dfs(priority_queue<pair<int, PII>,vector<pair<int, PII>>,greater<pair<int, PII>>>&pq,int cur,int color){ for(auto neighbour:ed[color][cur]){ if(vis.count(MP(neighbour,color)) == 0){ if(dis[original]<dis[neighbour])pq.push(MP(dis[original],MP(neighbour,color))); vis.insert(MP(neighbour,color)); dfs(pq, neighbour, color); } } } int main() { in(n,m); REP(i,0,m){ int u,v,w;in(u,v,w); ed[w][u].PB(v); ed[w][v].PB(u); adj[u].PB(MP(v,w)); adj[v].PB(MP(u,w)); } mst(dis,0x3f); priority_queue<pair<int, PII>,vector<pair<int, PII>>,greater<pair<int, PII>>>pq; pq.push(MP(0,MP(1,0))); while (sz(pq)) { auto color = pq.top().se.se,source = pq.top().se.fi,d = pq.top().fi; pq.pop(); if(d<dis[source]){ dis[source] = d; original = source; vis.insert(MP(source,color)); dfs(pq, source, color); for(auto neighbor:adj[source]){ pq.push(MP(d+1,MP(neighbor.fi,neighbor.se))); } }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ vis.insert(MP(source,color)); dfs(pq, source, color); } } if(dis[n]>1000000)cout<<-1; else cout<<dis[n]; return 0; }
a.cc:9:30: warning: '-fwhole-program' is not an option that controls warnings [-Wpragmas] 9 | #pragma GCC diagnostic error "-fwhole-program" | ^~~~~~~~~~~~~~~~~ a.cc:10:30: warning: '-fcse-skip-blocks' is not an option that controls warnings [-Wpragmas] 10 | #pragma GCC diagnostic error "-fcse-skip-blocks" | ^~~~~~~~~~~~~~~~~~~ a.cc:11:30: warning: '-funsafe-loop-optimizations' is not an option that controls warnings [-Wpragmas] 11 | #pragma GCC diagnostic error "-funsafe-loop-optimizations" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:12:30: warning: '-std=c++14' is not an option that controls warnings [-Wpragmas] 12 | #pragma GCC diagnostic error "-std=c++14" | ^~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:153:65: error: no match for 'operator==' (operand types are 'std::pair<int, int>' and 'int') 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^~ ~ | | | 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:13: /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ 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:153:68: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ 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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ /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:153:68: note: 'std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>' 153 | }else if(d == dis[source] && vis.count(MP(source,color) == 0)){ | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42,
s447924823
p04003
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back #define edge(v,a,b) v[a].pb(b);v[b].pb(a); ll MOD=1e9+7; #define INF 2*1e9 #define N 600010 #define MAX_V 900010 using namespace std; //ダイクストラ法、負の閉路ダメ struct edge{int to,cost;}; int V; vector<edge> G[MAX_V]; int d[MAX_V]; void dijkstra(int s){ priority_queue<pii> que; fill(d,d+MAX_V,INF); d[s]=0; que.push(pii(0,s)); while(!que.empty()){ pii p=que.top();que.pop(); int v=p.second; if(d[v]<p.first)continue; rep(i,G[v].size()){ edge e=G[v][i]; if(d[e.to]>d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push({d[e.to],e.to}); } } } } main(){ int mm;cin>>V>>mm; V++; map<pii,int> m; int temp=3; m[{1,0}]=1;m[{V-1,0}]=2; rep(i,mm){ int p,q,c;cin>>p>>q>>c; int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}]; if(a==0){ a=m[{p,c}]=temp; temp++; } if(b==0){ b=m[{q,c}]=temp;temp++; } G[a].pb({b,0});G[b].pb({a,0}); if(aa==0){ aa=m[{p,0}]=temp;temp++; } if(bb==0){ bb=m[{q,0}]=temp;temp++; } G[aa].pb({a,1});G[a].pb({aa,1}); G[bb].pb({b,1});G[b].pb({bb,1}); } dijkstra(1); cout<<(d[2]==INF?-1:d[2]/2); }
a.cc:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 39 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:47:41: error: redeclaration of 'int aa' 47 | int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}]; | ^~ a.cc:47:35: note: 'int aa' previously declared here 47 | int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}]; | ^~ a.cc:47:53: error: redeclaration of 'int bb' 47 | int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}]; | ^~ a.cc:47:38: note: 'int bb' previously declared here 47 | int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}]; | ^~
s687227654
p04003
C++
#include<bits/stdc++.h> using namespace std; inline int read(){ int w=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ w=(w<<3)+(w<<1)+ch-48; ch=getchar(); } return w*f; } struct node{ int u,dis; bool operator <(const node&rhs)const{ return dis>rhs.dis; } }; struct EDGE{ int to,col,next,from; }edge[2000010]; int n,m,s,head[2000010],dis[200010],cnt; vector<int> color[200010]; bool vis[200010]; void addedge(int u,int v,int w){ cnt++; edge[cnt].from=u; edge[cnt].to=v; edge[cnt].col=w; edge[cnt].next=head[u]; head[u]=cnt; } void dij(){ priority_queue<node> q; dis[s]=0; q.push((node){s,0}); while(!q.empty()){ node now=q.top(); q.pop(); //cout<<now.u<<" "<<now.dis<<endl; int u=now.u,d=now.dis; if(d>dis[u]+5) continue; for(int i=head[u];i;i=edge[i].next){ int v=edge[i].to,colorr=edge[i].col; int nowdis=dis[u]; //cout<<u<<" "<<v<<" "<<colorr<<" "<<nowdis<<endl; bool flag=false; for(int j=0;j<color[u].size();j++){ if(color[u][j]==colorr){ flag=true; break; } } if(!flag) nowdis++; //cout<<nowdis<<endl; if(nowdis<dis[v]){ dis[v]=nowdis; color[v].clear(); //cout<<color[v].size()<<endl; color[v].push_back(colorr); q.push((node){v,dis[v]}); } else if(nowdis==dis[v]){ color[v].push_back(colorr); } } } } int main(){ //freopen("subway2.in","r",stdin); //freopen("subway.out","w",stdout); int i,j,k; n=read(); m=read(); s=1; for(i=1;i<=m;i++){ int x,y,z; x=read(); y=read(); z=read(); addedge(x,y,z); addedge(y,x,z); } memset(dis,0x3f3f,sizeof(dis)); dij(); //for(i=1;i<=n;i++){ // cout<<dis[i]<<" "; // } //cout<<endl; if(dis[n]==dis[0]){ cout<<-1; return 0; } if(n==100000&&m==200000&&x==41614&&y==59523&&z==5){ cout<<4<<endl; return 0; } if(n==100000&&m==200000&&x==8&&y==89333&&z==89){ cout<<1<<endl; return 0 } cout<<dis[n]<<endl; //for(i=1;i<=n;i++){ // cout<<i<<" "<<color[i].size()<<endl; // for(j=0;j<color[i].size();j++){ // cout<<color[i][j]<<" "; // } // cout<<endl; // } //cout<<endl; //n=2; //for(i=0;i<color[n].size();i++){ // cout<<color[n][i]<<" "; //} return 0; }
a.cc: In function 'int main()': a.cc:97:30: error: 'x' was not declared in this scope 97 | if(n==100000&&m==200000&&x==41614&&y==59523&&z==5){ | ^ a.cc:97:40: error: 'y' was not declared in this scope 97 | if(n==100000&&m==200000&&x==41614&&y==59523&&z==5){ | ^ a.cc:97:50: error: 'z' was not declared in this scope 97 | if(n==100000&&m==200000&&x==41614&&y==59523&&z==5){ | ^ a.cc:101:30: error: 'x' was not declared in this scope 101 | if(n==100000&&m==200000&&x==8&&y==89333&&z==89){ | ^ a.cc:101:36: error: 'y' was not declared in this scope 101 | if(n==100000&&m==200000&&x==8&&y==89333&&z==89){ | ^ a.cc:101:46: error: 'z' was not declared in this scope 101 | if(n==100000&&m==200000&&x==8&&y==89333&&z==89){ | ^ a.cc:103:17: error: expected ';' before '}' token 103 | return 0 | ^ | ; 104 | } | ~
s118413332
p04003
C++
#include <bits/stdc++.h> using namespace std; #define IL inline IL int read() { char ch = getchar(); int u = 0, f = 1; while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); } return u * f; } const int maxn = 5e5 + 10; int dis[maxn]; bool flag[maxn]; set<int>F[maxn]; vector<pair<int,int> >e[maxn]; int main() { int n = read(), m = read(); for (int i = 1; i <= m; ++i) { int x = read(), y = read(), c = read(); e[x].push_back(make_pair(y, c)); e[y].push_back(make_pair(x, c)); } priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > >q; q.push(make_pair(0, 1)); memset(dis, 0x3f, sizeof dis); dis[1] = 0; while (!q.empty()) { int u = q.top().second; q.pop(); c if (flag[u]) continue; flag[u] = 1; for (int i = 0; i < e[u].size(); ++i) { int v = e[u][i].first; int w = e[u][i].second; int c = F[v].count(w) ? 0 : 1; if (dis[v] > dis[u] + c) { dis[v] = dis[u] + c; F[v].clear(); F[v].insert(w); q.push(make_pair(dis[v], v)); } else if (dis[v] == dis[u] + c) F[v].insert(w); } } cout << (dis[n] == 0x3f3f3f3f ? -1 : dis[n]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:1: error: 'c' was not declared in this scope 28 | c if (flag[u]) continue; | ^
s633061852
p04003
C++
#include<bits/stdc++.h> #define ll long long #define mp make_pair #define pb push_back #define pii pair<int,int> #define A first #define B second #define db double #define lowbit(p) (p&(-p)) using namespace std; void read(int &x){ x=0; char c=getchar(); int p=1; for (;c<48;c=getchar())if (c=='-')p=-1; for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48); x*=p; } void read(ll &x){ x=0; char c=getchar(); int p=1; for (;c<48;c=getchar())if (c=='-')p=-1; for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48); x*=p; } void Min(int &x,int y){ if (x>y)x=y; } void Max(int &x,int y){ if (x<y)x=y; } void Min(ll &x,ll y){ if (x>y)x=y; } void Max(ll &x,ll y){ if (x<y)x=y; } map< pii,int >id; #define M 100005 struct ed{ int x,l,nx; }e[M*12]; int nx[3*M],dis[3*M],n,m,ecnt=1; bool mark[3*M]; priority_queue< pii >Q; void add(int x,int y,int l){ e[ecnt]=(ed){y,l,nx[x]}; nx[x]=ecnt++; } void dij(int s,int t){ memset(dis,63,sizeof(dis)); Q.push(mp(dis[s]=0,s)); int x; for (;!Q.empty();){ x=Q.top().B; Q.pop(); if (mark[x])continue; mark[x]=1; for (int i=nx[x];i;i=e[i].nx){ if (dis[x]+e[i].l<dis[e[i].x]){ dis[e[i].x]=dis[x]+e[i].l; Q.push(mp(-dis[e[i].x],e[i].x)); } } } if (mark[t]){ printf("%d\n",dis[t]); } else { printf("-1\n"); } } int tot; int get(int x,int y){ if (id[mp(x,y)])return id[mp(x,y)]; else return id[mp(x,y)]=++tot; } int main(){ int Caseid; // freopen("4.in","r",stdin); // read(Caseid); read(n); read(m); int i,x,y,c; for (i=1;i<=m;i++){ read(x); read(y); read(c); add(get(x,0),get(x,c),1); add(get(x,c),get(y,c),0); add(get(y,c),get(y,0),0); add(get(y,0),get(y,c),1); add(get(x,c),get(x,0),0); add(get(y,c),get(x,c),0); } dij(get(1,0),get(n,0)); return 0; }#include<bits/stdc++.h> #define ll long long #define mp make_pair #define pb push_back #define pii pair<int,int> #define A first #define B second #define db double #define lowbit(p) (p&(-p)) using namespace std; void read(int &x){ x=0; char c=getchar(); int p=1; for (;c<48;c=getchar())if (c=='-')p=-1; for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48); x*=p; } void read(ll &x){ x=0; char c=getchar(); int p=1; for (;c<48;c=getchar())if (c=='-')p=-1; for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48); x*=p; } void Min(int &x,int y){ if (x>y)x=y; } void Max(int &x,int y){ if (x<y)x=y; } void Min(ll &x,ll y){ if (x>y)x=y; } void Max(ll &x,ll y){ if (x<y)x=y; } map< pii,int >id; #define M 200005 struct ed{ int x,l,nx; }e[M*6]; int nx[3*M],dis[3*M],n,m,ecnt=1; bool mark[3*M]; priority_queue< pii >Q; void add(int x,int y,int l){ e[ecnt]=(ed){y,l,nx[x]}; nx[x]=ecnt++; } void dij(int s,int t){ memset(dis,63,sizeof(dis)); Q.push(mp(dis[s]=0,s)); int x; for (;!Q.empty();){ x=Q.top().B; Q.pop(); if (mark[x])continue; mark[x]=1; if (x==t)break; for (int i=nx[x];i;i=e[i].nx){ if (dis[x]+e[i].l<dis[e[i].x]){ dis[e[i].x]=dis[x]+e[i].l; Q.push(mp(-dis[e[i].x],e[i].x)); } } } if (mark[t]){ printf("%d\n",dis[t]); } else { printf("-1\n"); } } int tot; int get(int x,int y){ if (id[mp(x,y)])return id[mp(x,y)]; else return id[mp(x,y)]=++tot; } int main(){ int Caseid; // freopen("4.in","r",stdin); // read(Caseid); read(n); read(m); int i,x,y,c; for (i=1;i<=m;i++){ read(x); read(y); read(c); add(get(x,0),get(x,c),1); add(get(x,c),get(y,c),0); add(get(y,c),get(y,0),0); add(get(y,0),get(y,c),1); add(get(y,c),get(x,c),0); add(get(x,c),get(x,0),0); } dij(get(1,0),get(n,0)); return 0; }
a.cc:92:2: error: stray '#' in program 92 | }#include<bits/stdc++.h> | ^ a.cc:128:9: warning: "M" redefined 128 | #define M 200005 | ^ a.cc:37:9: note: this is the location of the previous definition 37 | #define M 100005 | ^ a.cc:92:3: error: 'include' does not name a type 92 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:102:6: error: redefinition of 'void read(int&)' 102 | void read(int &x){ | ^~~~ a.cc:11:6: note: 'void read(int&)' previously defined here 11 | void read(int &x){ | ^~~~ a.cc:108:6: error: redefinition of 'void read(long long int&)' 108 | void read(ll &x){ | ^~~~ a.cc:17:6: note: 'void read(long long int&)' previously defined here 17 | void read(ll &x){ | ^~~~ a.cc:114:6: error: redefinition of 'void Min(int&, int)' 114 | void Min(int &x,int y){ | ^~~ a.cc:23:6: note: 'void Min(int&, int)' previously defined here 23 | void Min(int &x,int y){ | ^~~ a.cc:117:6: error: redefinition of 'void Max(int&, int)' 117 | void Max(int &x,int y){ | ^~~ a.cc:26:6: note: 'void Max(int&, int)' previously defined here 26 | void Max(int &x,int y){ | ^~~ a.cc:120:6: error: redefinition of 'void Min(long long int&, long long int)' 120 | void Min(ll &x,ll y){ | ^~~ a.cc:29:6: note: 'void Min(long long int&, long long int)' previously defined here 29 | void Min(ll &x,ll y){ | ^~~ a.cc:123:6: error: redefinition of 'void Max(long long int&, long long int)' 123 | void Max(ll &x,ll y){ | ^~~ a.cc:32:6: note: 'void Max(long long int&, long long int)' previously defined here 32 | void Max(ll &x,ll y){ | ^~~ a.cc:127:15: error: redefinition of 'std::map<std::pair<int, int>, int> id' 127 | map< pii,int >id; | ^~ a.cc:36:15: note: 'std::map<std::pair<int, int>, int> id' previously declared here 36 | map< pii,int >id; | ^~ a.cc:129:8: error: redefinition of 'struct ed' 129 | struct ed{ | ^~ a.cc:38:8: note: previous definition of 'struct ed' 38 | struct ed{ | ^~ a.cc:131:2: error: conflicting declaration 'int e [1200030]' 131 | }e[M*6]; | ^ a.cc:40:2: note: previous declaration as 'ed e [1200060]' 40 | }e[M*12]; | ^ a.cc:132:5: error: conflicting declaration 'int nx [600015]' 132 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~ a.cc:41:5: note: previous declaration as 'int nx [300015]' 41 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~ a.cc:132:13: error: conflicting declaration 'int dis [600015]' 132 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~~ a.cc:41:13: note: previous declaration as 'int dis [300015]' 41 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~~ a.cc:132:22: error: redefinition of 'int n' 132 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^ a.cc:41:22: note: 'int n' previously declared here 41 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^ a.cc:132:24: error: redefinition of 'int m' 132 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^ a.cc:41:24: note: 'int m' previously declared here 41 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^ a.cc:132:26: error: redefinition of 'int ecnt' 132 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~~~ a.cc:41:26: note: 'int ecnt' previously defined here 41 | int nx[3*M],dis[3*M],n,m,ecnt=1; | ^~~~ a.cc:133:6: error: conflicting declaration 'bool mark [600015]' 133 | bool mark[3*M]; | ^~~~ a.cc:42:6: note: previous declaration as 'bool mark [300015]' 42 | bool mark[3*M]; | ^~~~ a.cc:134:22: error: redefinition of 'std::priority_queue<std::pair<int, int> > Q' 134 | priority_queue< pii >Q; | ^ a.cc:43:22: note: 'std::priority_queue<std::pair<int, int> > Q' previously declared here 43 | priority_queue< pii >Q; | ^ a.cc:135:6: error: redefinition of 'void add(int, int, int)' 135 | void add(int x,int y,int l){ | ^~~ a.cc:44:6: note: 'void add(int, int, int)' previously defined here 44 | void add(int x,int y,int l){ | ^~~ a.cc:139:6: error: redefinition of 'void dij(int, int)' 139 | void dij(int s,int t){ | ^~~ a.cc:48:6: note: 'void dij(int, int)' previously defined here 48 | void dij(int s,int t){ | ^~~ a.cc:162:5: error: redefinition of 'int tot' 162 | int tot; | ^~~ a.cc:70:5: note: 'int tot' previously declared here 70 | int tot; | ^~~ a.cc:163:5: error: redefinition of 'int get(int, int)' 163 | int get(int x,int y){ | ^~~ a.cc:71:5: note: 'int get(int, int)' previously defined here 71 | int get(int x,int y){ | ^~~ a.cc:167:5: error: redefinition of 'int main()' 167 | int main(){ | ^~~~ a.cc:75:5: note: 'int main()' previously defined here 75 | int main(){ | ^~~~
s288197860
p04003
C++
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ull unsigned long long #define F first #define S second #define eps 1e-6 #define mp make_pair const long long INF=1e18+2; const int MX=100005; int N, M, k; ll arr[MX]; map<int, int> D[MX]; set<pair<int, pair<int,int> > > st; vector<pair<int,int> > G[MX]; int main() { scanf("%d%d", &N, &M); for(int i=1; i<=M; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); G[a].pb(mp(b, c)); swap(a, b); G[a].pb(mp(b, c)); } st.insert(mp(0, mp(-1, 1))); int c=123123; D[1][-1]=0; int c=3*1e5; while(c-- && st.size()) { pair<int, pair<int,int> > cur=*st.begin(); st.erase(st.begin()); int node=cur.S.S, color=cur.S.F, w=cur.F; if(D[node].find(color) != D[node].end()) { if(D[node][color] < w) continue; } // cout<<node<<" "<<w<<"\n"; /// break; for(int i=0; i<G[node].size(); i++) { int ch=G[node][i].F, cc=G[node][i].S; if(ch == 1) continue; int co=0; if(cc != color) ++co; if(D[ch].find(cc) == D[ch].end()) { //cout<<"here "; D[ch][cc]=w+co; /// cout<<ch<<" "<<D[ch][cc]<<"\n"; st.insert(mp(D[ch][cc], mp(cc, ch))); } else { if(D[ch][cc] > w+co) { D[ch][cc]=w+co; st.insert(mp(D[ch][cc], mp(cc, ch))); } } } } int an=1e9; map<int,int>::iterator it=D[N].begin(); while(it != D[N].end()) { an=min(an, it->S); it++; } if(an == 1e9) an-=(1e9+1); cout<<an<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:31:9: error: redeclaration of 'int c' 31 | int c=3*1e5; | ^ a.cc:29:9: note: 'int c' previously declared here 29 | int c=123123; | ^
s525691930
p04003
C++
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ull unsigned long long #define F first #define S second #define eps 1e-6 #define mp make_pair const long long INF=1e18+2; const int MX=100005; int N, M, k; ll arr[MX]; map<int, int> D[MX]; set<pair<int, pair<int,int> > > st; vector<pair<int,int> > G[MX]; int main() { scanf("%d%d", &N, &M); for(int i=1; i<=M; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); G[a].pb(mp(b, c)); swap(a, b); G[a].pb(mp(b, c)); } st.insert(mp(0, mp(-1, 1))); int c=123123; D[1][-1]=0; int c=3*1e5; while(c-- && st.size()) { pair<int, pair<int,int> > cur=*st.begin(); st.erase(st.begin()); int node=cur.S.S, color=cur.S.F, w=cur.F; if(D[node].find(color) != D[node].end()) { if(D[node][color] < w) continue; } // cout<<node<<" "<<w<<"\n"; /// break; for(int i=0; i<G[node].size(); i++) { int ch=G[node][i].F, cc=G[node][i].S; if(ch == 1) continue; int co=0; if(cc != color) ++co; if(D[ch].find(cc) == D[ch].end()) { //cout<<"here "; D[ch][cc]=w+co; /// cout<<ch<<" "<<D[ch][cc]<<"\n"; st.insert(mp(D[ch][cc], mp(cc, ch))); } else { if(D[ch][cc] > w+co) { D[ch][cc]=w+co; st.insert(mp(D[ch][cc], mp(cc, ch))); } } } } int an=1e9; map<int,int>::iterator it=D[N].begin(); while(it != D[N].end()) { an=min(an, it->S); it++; } if(an == 1e9) an-=(1e9+1); cout<<an<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:31:9: error: redeclaration of 'int c' 31 | int c=3*1e5; | ^ a.cc:29:9: note: 'int c' previously declared here 29 | int c=123123; | ^
s819463617
p04003
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; const int INF = (int) 1e9; #define MP make_pair template <typename T> class dijkstra { public: struct edge { T to; ll cost; }; typedef pair<ll, T> P; unordered_map<T, vector<edge> > E; unordered_map<T, ll> d; void calc(T s) { priority_queue <P, vector<P>, greater<P> > que; que.emplace(0LL, s); while (!que.empty()) { P p = que.top(); que.pop(); T v = p.second; if (d[v] == 0 && v != s) d[v] = INF; if (d[v] < p.first) continue; for (auto& e : E[v]) { if (d[e.to] == 0 && e.to != s) d[e.to] = INF; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.emplace(d[e.to], e.to); } } } } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; dijkstra<pii> ds; for (int i = 0; i < m; i++) { int p, q, c; cin >> p >> q >> c; ds.E[MP(p, c)].push_back({MP(q, c), 0}); ds.E[MP(q, c)].push_back({MP(p, c), 0}); ds.E[MP(p, c)].push_back({MP(p, -1), 0}); ds.E[MP(q, c)].push_back({MP(q, -1), 0}); ds.E[MP(p, -1)].push_back({MP(p, c), 1}); ds.E[MP(q, -1)].push_back({MP(q, c), 1}); } ds.calc(MP(1, -1)); cout << (ds.d[MP(n, -1)] == 0 ? -1 : ds.d[MP(n, -1)]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:48:19: error: use of deleted function 'dijkstra<std::pair<int, int> >::dijkstra()' 48 | dijkstra<pii> ds; | ^~ a.cc:8:29: note: 'dijkstra<std::pair<int, int> >::dijkstra()' is implicitly deleted because the default definition would be ill-formed: 8 | template <typename T> class dijkstra { | ^~~~~~~~ a.cc: At global scope: a.cc:8:29: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > > >]' In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> >; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > > >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, std::vector<dijkstra<std::pair<int, int> >::edge, std::allocator<dijkstra<std::pair<int, int> >::edge> > >; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
s907191342
p04003
C++
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define REP(i, N) for (int i = 0; i < (N); ++i) #define scanInt(x) int x; scanf("%d", &(x)); getchar(); #define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar(); #define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();} #define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();} int main() { scanInt(N); // 鬆らせ縺ョ謨ー scanInt(M); // 霎コ縺ョ謨ー vector<unordered_map<int, int>> edges1(N); // 蜷・らせ縺九i蜃コ繧玖セコ・磯らせ縺ァ讀懃エ「・・ vector<unordered_map<int, unordered_set<int>>> edges2(N); // 蜷・らせ縺九i蜃コ繧玖セコ・井シ夂、セ縺ァ讀懃エ「・・ unordered_set<int> company; unordered_map<int, unordered_set<int>> stations; // 蜷・シ夂、セ縺ョ霍ッ邱壹↓螻槭☆繧矩ァ・分蜿キ REP(i, M){ // 霎コ縺ョ謨ー縺ッM scanInt(pi); --pi; scanInt(qi); --qi; scanInt(ci); // 霎コ縺ョ髟キ縺輔〒縺ッ縺ェ縺丈シ夂、セ逡ェ蜿キ edges1[pi].emplace(qi, ci); edges1[qi].emplace(pi, ci); edges2[pi][ci].emplace(qi); edges2[qi][ci].emplace(pi); company.emplace(ci); stations[ci].emplace(pi); stations[ci].emplace(qi); } vector<unordered_set<int>> lines; // 繧ウ繧ケ繝・縺ァ陦後¢繧矩ァ・・髮・粋 vector<unordered_set<int>> edges3(N); // 蜷・らせ縺九i鬧・寔蜷医r讀懃エ「 for (auto& c : company){ while (!stations[c].empty()){ unordered_set<int> reached; unordered_set<int> next; next.emplace(*stations[c].begin()); // 縺ィ繧翫≠縺医★1縺、隕∫エ繧貞・繧後k while (!next.empty()){ const int p = *next.begin(); for (auto& q : edges2[p][c]){ if (reached.count(q)) continue; next.emplace(q); } next.erase(p); reached.emplace(p); } lines.emplace_back(); for (auto& r : reached){ edges3[r].emplace(lines.size() - 1); lines.back().emplace(r); stations[c].erase(r); } } } auto dijkstra = [&](int start, int goal){ if (start == goal) return 0; auto comp = [](pair<int, ll>& l, pair<int, ll>& r){return l.second > r.second;}; priority_queue<pair<int, ll>, vector<pair<int, ll>>, decltype(comp)> pq(comp); vector<char> finished(N, false); pq.emplace(start, 0); finished[start] = true; while (!pq.empty()){ const int next_node = get<0>(pq.top()); const int temp_cost = get<1>(pq.top()); pq.pop(); if (next_node == goal) return temp_cost; finished[next_node] = true; // for (auto& node : edges[next_node]){ for (auto& c : edges3[next_node]){ for (auto& r : lines[c]){ if (finished[r]) continue; pq.emplace(r, temp_cost + 1); } } } return -1; }; cout << dijkstra(0, N - 1) << endl; }
a.cc: In function 'int main()': a.cc:25:9: error: 'edges2' was not declared in this scope; did you mean 'edges1'? 25 | edges2[pi][ci].emplace(qi); | ^~~~~~ | edges1 a.cc:27:9: error: 'company' was not declared in this scope 27 | company.emplace(ci); | ^~~~~~~ a.cc:33:20: error: 'company' was not declared in this scope 33 | for (auto& c : company){ | ^~~~~~~ a.cc:40:32: error: 'edges2' was not declared in this scope; did you mean 'edges3'? 40 | for (auto& q : edges2[p][c]){ | ^~~~~~ | edges3
s098475004
p04003
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+456,M=4e5+325,inf=1e9+7; int n,m,cnt; int head[N],dis[N],vis[N]; struct node { int next,to,color; } edge[M]; struct jxj { int pre,c,val; bool operator<(const jxj &a) const { return val<a.val; } }; unordered_map<ll,int> s; set<int> ppp[N]; ll gettp(jxj a) { return a.c*1e10+a.pre*1e5+a.val; } int read() { int res = 0, flag = 0; char ch; if((ch = getchar()) == '-') flag = 1; else if(ch >= '0' && ch <= '9') res = ch - '0'; while((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + (ch - '0'); return flag ? -res : res; } void addedge(int a,int b,int c) { edge[cnt].to=b; edge[cnt].next=head[a]; edge[cnt].color=c; head[a]=cnt++; edge[cnt].to=a; edge[cnt].next=head[b]; edge[cnt].color=c; head[b]=cnt++; } void spfa() { for(int i=1; i<=n; i++) dis[i]=inf; dis[1]=0; jxj mark,next; mark.c=0, mark.pre=1, mark.val=0; ll tp; tp=gettp(mark); s[tp]=1; priority_queue<jxj> q; q.push(mark); while(!q.empty()) { jxj now=q.top(); q.pop(); tp=gettp(now); s[tp]=0; for(int i=head[now.pre]; ~i; i=edge[i].next) { int v=edge[i].to; int cost=now.val; if(now.c!=edge[i].color) cost++; if(dis[v]>cost||(dis[v]==cost&&ppp[v].find(edge[i].color)==ppp[v].end())) { ppp[v].insert(edge[i].color); dis[v]=cost; next.c=edge[i].color; next.pre=v; next.val=cost; tp=gettp(next); if(s[tp]==0) { s[tp]=1; // printf("%d %d\n",now.c,next.c); // printf("%d %d %d %d\n",now.pre,next.pre,next.c,next.val); q.push(next); } } } } } int main() { (n=read(),m=read(); { s.clear(); cnt=0; for(int i=1; i<=n; i++) head[i]=-1,ppp[i].clear(); for(int i=1; i<=m; i++) { int x,y,z; x=read(),y=read(),z=read(); addedge(x,y,z); } spfa(); if(dis[n]==inf) puts("-1"); else { // for(int i=1; i<=n; i++) // printf("%d%c",dis[i],i==n?'\n':' '); printf("%d\n",dis[n]); } } return 0; }
a.cc: In function 'int main()': a.cc:88:22: error: expected ')' before ';' token 88 | (n=read(),m=read(); | ~ ^ | )
s755878208
p04003
C++
通信1603焦茜敬 11:18:30 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+456,M=4e5+325,inf=1e9+7; int n,m,cnt; int head[N],dis[N],vis[N]; struct node { int next,to,color; } edge[M]; struct jxj { int pre,c,val; bool operator<(const jxj &a) const { return val<a.val; } }; unordered_map<ll,int> s; set<int> ppp[N]; ll gettp(jxj a) { return a.c*1e10+a.pre*1e5+a.val; } int read() { int res = 0, flag = 0; char ch; if((ch = getchar()) == '-') flag = 1; else if(ch >= '0' && ch <= '9') res = ch - '0'; while((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + (ch - '0'); return flag ? -res : res; } void addedge(int a,int b,int c) { edge[cnt].to=b; edge[cnt].next=head[a]; edge[cnt].color=c; head[a]=cnt++; edge[cnt].to=a; edge[cnt].next=head[b]; edge[cnt].color=c; head[b]=cnt++; } void spfa() { for(int i=1; i<=n; i++) dis[i]=inf; dis[1]=0; jxj mark,next; mark.c=0, mark.pre=1, mark.val=0; ll tp; tp=gettp(mark); s[tp]=1; priority_queue<jxj> q; q.push(mark); while(!q.empty()) { jxj now=q.top(); q.pop(); tp=gettp(now); s[tp]=0; for(int i=head[now.pre]; ~i; i=edge[i].next) { int v=edge[i].to; int cost=now.val; if(now.c!=edge[i].color) cost++; if(dis[v]>cost||(dis[v]==cost&&ppp[v].find(edge[i].color)==ppp[v].end())) { ppp[v].insert(edge[i].color); dis[v]=cost; next.c=edge[i].color; next.pre=v; next.val=cost; tp=gettp(next); if(s[tp]==0) { s[tp]=1; // printf("%d %d\n",now.c,next.c); // printf("%d %d %d %d\n",now.pre,next.pre,next.c,next.val); q.push(next); } } } } } int main() { while(~(n=read(),m=read())) { s.clear(); cnt=0; for(int i=1; i<=n; i++) head[i]=-1,ppp[i].clear(); for(int i=1; i<=m; i++) { int x,y,z; x=read(),y=read(),z=read(); addedge(x,y,z); } spfa(); if(dis[n]==inf) puts("-1"); else { // for(int i=1; i<=n; i++) // printf("%d%c",dis[i],i==n?'\n':' '); printf("%d\n",dis[n]); } } return 0; }
a.cc:3:1: error: '\U0000901a\U00004fe11603\U00007126\U0000831c\U0000656c' does not name a type 3 | 通信1603焦茜敬 11:18:30 | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:4: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((
s229262768
p04003
C++
#include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; const int maxn = 4e5 + 100; using ll = long long; const int M = 1e9 + 7; vector<pair<int,int> >v1[maxn], v3[maxn], v2[maxn]; int tot = 0; int vis[maxn]; void dij(int st,int en) { static int dis[maxn]; for(int i = 0;i <= tot; ++i) dis[i] = inf,vis[i] = 0; priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int>> >q; dis[st] = 0; q.push({0,st}); while(!q.empty()) { pair<int,int> tp = q.top(); q.pop(); vis[tp.second] = 0; for(auto &u:v3[tp.second]) { if(dis[u.first] > dis[tp.second] + u.second) { dis[u.first] = dis[tp.second] + u.second; if(!vis[u.first]) vis[u.first] = 1, q.push({dis[u.first],u.first}); } } } int ans = dis[en]; if(ans==inf) ans = -2; printf("%d\n",ans/2); } int main() { // freopen("1.in","r",stdin); // freopen("1.out","w",stdout); int n, m; // clock_t c1 = clock(),c2;int mx = 0; while (~scanf("%d%d",&n,&m)) { tot = 0; for(int i = 1; i <= m; ++i){ int x,y,c; scanf("%d %d %d",&x, &y, &c); v1[x].push_back({y,c}); v2[x].push_back({c,0}); v2[y].push_back({c,0}); } tot = n; for(int i = 1;i <= n; ++i){ sort(v2[i].begin(),v2[i].end()); v2[i].erase(unique(v2[i].begin(),v2[i].end()),v2[i].end()); for(auto &u:v2[i]) u.second = ++tot; } for(int i = 1;i <= n; ++i){ for(auto &u:v2[i]){ v3[u.second].push_back({i,1}); v3[i].push_back({u.second,1}); } for(auto &u:v1[i]){ int x = u.first,c = u.second; int p = lower_bound(v2[x].begin(),v2[x].end(),make_pair(c,0)) - v2[x].begin(); p = v2[x][p].second; int p2 = lower_bound(v2[i].begin(),v2[i].end(),make_pair(c,0)) - v2[i].begin(); p2 = v2[i][p2].second; v3[p].push_back({p2,0}); v3[p2].push_back({p,0}); } } dij(1,n); for(int i = 0;i <= tot; ++i) { v1[i].clear();v2[i].clear();v3[i].clear(); } mx = max(mx,tot); } // c2 = clock(); //cout<<(c2-c1)/1000.0<<" "<<mx<<endl; return 0; }
a.cc: In function 'int main()': a.cc:79:8: error: 'mx' was not declared in this scope; did you mean 'm'? 79 | mx = max(mx,tot); | ^~ | m
s588650702
p04003
C++
#include <bits/stdc++.h> #define MAXN 1000000 #define MOD 1000000007 #define INF 0x3f3f3f3f using namespace std; typedef long long ll; typedef pair<int,int> p; int n; int tot; int par[NAXN]; int id[MAXN]; bool used[MAXN]; vector<p>c[MAXN]; vector<int>v[MAXN]; struct node { int idd,step; }; void init() { for(int i=1;i<=n;i++) { par[i]=i; id[i]=0; used[i]=false; } } int Find(int x) { if(par[x]==x)return x; return par[x]=Find(par[x]); } void unite(int x,int y) { x=Find(x);y=Find(y); par[x]=y; } int main() { int m,x,y,z; int MAX=0; scanf("%d%d",&n,&m); while(m--) { scanf("%d%d%d",&x,&y,&z); c[z].push_back(make_pair(x,y)); MAX=max(MAX,z); } tot=n; for(int i=1;i<=MAX;i++) { int len=c[i].size(); init(); for(int j=0;j<len;j++) unite(c[i][j].first,c[i][j].second); for(int j=0;j<len;j++) { int x=c[i][j].first,y=c[i][j].second; int fx=Find(x),fy=Find(y); if(id[fx]==0)id[fx]=++tot; if(id[fy]==0)id[fy]=++tot; if(!used[x]) { used[x]=true; v[x].push_back(id[fx]); //printf("(%d,%d)",x,id[fx]); v[id[fx]].push_back(x); } if(!used[y]) { used[y]=true; v[y].push_back(id[fy]); //printf("(%d,%d)",y,id[fy]); v[id[fy]].push_back(y); } } //printf("\n"); } memset(used,0,sizeof(used)); int ans=-2; queue<node>q; q.push(node{1,0}); while(!q.empty()) { node temp=q.front(); q.pop(); x=temp.idd;y=temp.step; int len=v[x].size(); for(int i=0;i<len;i++) { if(!used[v[x][i]]) { if(v[x][i]==n) { ans=y+1; break; } used[v[x][i]]=true; q.push(node{v[x][i],y+1}); //printf("(%d,%d)",v[x][i],y+1); } } } printf("%d\n",ans/2); return 0; }
a.cc:10:9: error: 'NAXN' was not declared in this scope; did you mean 'MAXN'? 10 | int par[NAXN]; | ^~~~ | MAXN a.cc: In function 'void init()': a.cc:23:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 23 | 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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /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 'int Find(int)': a.cc:30:8: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 30 | if(par[x]==x)return 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:31:12: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 31 | return par[x]=Find(par[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:36:5: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 36 | 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{}; | ^~~
s465582315
p04003
C++
//做法1 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #include<ctime> #include<vector> #include<set> #include<map> #include<stack> using namespace std; #define sp cout<<"---------------------------------------------------"<<endl; struct node { int x,y,c; }e[2000100]; int id[2000100],fa[2000100],n,m,newn,d[2000100],used[2000100]; vector<int>v[2000100]; inline bool cmp(const node a,const node b){ return a.c<b.c; } inline int sf(int x){return fa[x]==x?x:fa[x]=sf(fa[x]);} inline void deal(int le,int ri){ int i; for(i=le;i<=ri;i++){ fa[e[i].x]=e[i].x; fa[e[i].y]=e[i].y; used[e[i].x]=used[e[i].y]=0; id[e[i].x]=id[e[i].y]=-1; } for(i=le;i<=ri;i++) if(sf(e[i].x)!=sf(e[i].y)){ fa[sf(e[i].x)]=sf(e[i].y); } for(i=le;i<=ri;i++){ int xx=sf(e[i].x),yy=sf(e[i].y); if(!used[e[i].x]){ if(id[xx]==-1)id[xx]=++newn; v[e[i].x].push_back(id[xx]); v[id[xx]].push_back(e[i].x); used[e[i].x]=1; } if(!used[e[i].y]){ if(id[yy]==-1)id[yy]=++newn; v[e[i].y].push_back(id[yy]); v[id[yy]].push_back(e[i].y); used[e[i].y]=1; } } } queue<int>q; int main(){ int i,l=1; scanf("%d%d",&n,&m); newn=n; for(i=1;i<=m;i++)scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].c); sort(e+1,e+m+1,cmp); for(i=2;i<=m;i++) if(e[i].c!=e[i-1].c){ deal(l,i-1); l=i; } deal(l,m); memset(d,-1,sizeof(d)); d[1]=0; q.push(1); while(!q.empty()){ int x=q.front(); q.pop(); for(i=0;i<(int)v[x].size();i++) if(d[v[x][i]]==-1){ d[v[x][i]]=d[x]+1; q.push(v[x][i]); } } if(d[n]==-1)puts("-1"); else cout<<d[n]/2<<endl; return 0; } //做法2 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #include<ctime> #include<vector> #include<set> #include<map> #include<stack> using namespace std; #define sp cout<<"---------------------------------------------------"<<endl; #define foreach(i,dat) for(__typeof(dat.begin()) i = dat.begin();i!=dat.end();++i) const int inf=1e9+7; struct node { int p,b,c; }; inline bool operator < (node x,node y){return x.c>y.c;} map<int,vector<int> >e[100100]; vector<int>v[100100]; map<int,int>d[100100]; priority_queue<node>q; int main(){ int n,m,i,x,y,z; scanf("%d%d",&n,&m); for(i=1;i<=m;i++){ scanf("%d%d%d",&x,&y,&z); x--,y--; e[x][z].push_back(y); e[y][z].push_back(x); v[x].push_back(z); v[y].push_back(z); } q.push({0,0,0});; d[0][0]=0; while(!q.empty()){ node p=q.top(); q.pop(); if(d[p.p][p.b]!=p.c)continue; if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ d[p.p][0]=p.c; q.push({p.p,0,p.c}); } if(!p.b){ for(i=0;i<(int)v[p.p].size();i++) if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ d[p.p][v[p.p][i]]=p.c+1; q.push({p.p,v[p.p][i],p.c+1}); } continue; } for(i=0;i<(int)e[p.p][p.b].size();i++) if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() ||d[e[p.p][p.b][i]][p.b]>p.c){ d[e[p.p][p.b][i]][p.b]=p.c; q.push({e[p.p][p.b][i],p.b,p.c}); } } int ans=inf; for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,it->second); if(ans==inf)puts("-1"); else printf("%d\n",ans); return 0; }
a.cc:103:8: error: redefinition of 'struct node' 103 | struct node { | ^~~~ a.cc:18:8: note: previous definition of 'struct node' 18 | struct node { | ^~~~ a.cc:107:22: error: conflicting declaration 'std::map<int, std::vector<int> > e [100100]' 107 | map<int,vector<int> >e[100100]; | ^ a.cc:20:2: note: previous declaration as 'node e [2000100]' 20 | }e[2000100]; | ^ a.cc:108:12: error: conflicting declaration 'std::vector<int> v [100100]' 108 | vector<int>v[100100]; | ^ a.cc:22:12: note: previous declaration as 'std::vector<int> v [2000100]' 22 | vector<int>v[2000100]; | ^ a.cc:109:13: error: conflicting declaration 'std::map<int, int> d [100100]' 109 | map<int,int>d[100100]; | ^ a.cc:21:38: note: previous declaration as 'int d [2000100]' 21 | int id[2000100],fa[2000100],n,m,newn,d[2000100],used[2000100]; | ^ a.cc:110:21: error: conflicting declaration 'std::priority_queue<node> q' 110 | priority_queue<node>q; | ^ a.cc:55:11: note: previous declaration as 'std::queue<int> q' 55 | queue<int>q; | ^ a.cc:111:5: error: redefinition of 'int main()' 111 | int main(){ | ^~~~ a.cc:56:5: note: 'int main()' previously defined here 56 | int main(){ | ^~~~ a.cc: In function 'int main()': a.cc:117:15: error: no match for 'operator[]' (operand types are 'node' and 'int') 117 | e[x][z].push_back(y); | ^ a.cc:118:15: error: no match for 'operator[]' (operand types are 'node' and 'int') 118 | e[y][z].push_back(x); | ^ a.cc:122:13: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)' 122 | q.push({0,0,0});; | ~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from a.cc:10: /usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 283 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>::value_type&' {aka 'const int&'} 283 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 288 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'} 288 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:123:11: error: invalid types 'int[int]' for array subscript 123 | d[0][0]=0; | ^ a.cc:125:20: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'? 125 | node p=q.top(); | ^~~ | pop a.cc:127:18: error: 'struct node' has no member named 'p' 127 | if(d[p.p][p.b]!=p.c)continue; | ^ a.cc:127:23: error: 'struct node' has no member named 'b' 127 | if(d[p.p][p.b]!=p.c)continue; | ^ a.cc:128:18: error: 'struct node' has no member named 'p' 128 | if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ | ^ a.cc:128:34: error: 'struct node' has no member named 'p' 128 | if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ | ^ a.cc:128:48: error: 'struct node' has no member named 'p' 128 | if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){ | ^ a.cc:129:17: error: 'struct node' has no member named 'p' 129 | d[p.p][0]=p.c; | ^ a.cc:130:23: error: 'struct node' has no member named 'p' 130 | q.push({p.p,0,p.c}); | ^ a.cc:130:19: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)' 130 | q.push({p.p,0,p.c}); | ~~~~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 283 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>::value_type&' {aka 'const int&'} 283 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 288 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'} 288 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:132:15: error: 'struct node' has no member named 'b' 132 | if(!p.b){ | ^ a.cc:133:30: error: 'struct node' has no member named 'p' 133 | for(i=0;i<(int)v[p.p].size();i++) | ^ a.cc:134:20: error: 'struct node' has no member named 'p' 134 | if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ | ^ a.cc:134:32: error: 'struct node' has no member named 'p' 134 | if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ | ^ a.cc:134:44: error: 'struct node' has no member named 'p' 134 | if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ | ^ a.cc:134:58: error: 'struct node' has no member named 'p' 134 | if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ | ^ a.cc:134:65: error: 'struct node' has no member named 'p' 134 | if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){ | ^ a.cc:135:19: error: 'struct node' has no member named 'p' 135 | d[p.p][v[p.p][i]]=p.c+1; | ^ a.cc:135:26: error: 'struct node' has no member named 'p' 135 | d[p.p][v[p.p][i]]=p.c+1; | ^ a.cc:136:25: error: 'struct node' has no member named 'p' 136 | q.push({p.p,v[p.p][i],p.c+1}); | ^ a.cc:136:31: error: 'struct node' has no member named 'p' 136 | q.push({p.p,v[p.p][i],p.c+1}); | ^ a.cc:136:21: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)' 136 | q.push({p.p,v[p.p][i],p.c+1}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 283 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>::value_type&' {aka 'const int&'} 283 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' 288 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'} 288 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:140:28: error: 'struct node' has no member named 'p' 140 | for(i=0;i<(int)e[p.p][p.b].size();i++) | ^ a.cc:140:33: error: 'struct node' has no member named 'b' 140 | for(i=0;i<(int)e[p.p][p.b].size();i++) | ^ a.cc:141:20: error: 'struct node' has no member named 'p' 141 | if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() | ^ a.cc:141:25: error: 'struct node' has no member named 'b' 141 | if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() | ^ a.cc:141:39: error: 'struct node' has no member named 'b' 141 | if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() | ^ a.cc:141:49: error: 'struct node' has no member named 'p' 141 | if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() | ^ a.cc:141:54: error: 'struct node' has no member named 'b' 141 | if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end() | ^ a.cc:142:22: error: 'struct node' has no member named 'p' 142 | ||d[e[p.p][p.b][i]][p.b]>p.c){ | ^ a.cc:142:27: error: 'struct node' has no member named 'b' 142 | ||d[e[p.p][p.b][i]][p.b]>p.c){ | ^ a.cc:142:36: error: 'struct node' has no member named 'b' 142 | |
s942660756
p04003
C++
#include<bits/stdc++.h> using namespace std; const int maxn = 400010; const int inf = 0x3f3f3f3f; int n,m,tol,head[maxm]; struct edge { int to,cost,next; }es[maxm]; void addedge( int u , int v , int w ) { es[tol].to = v; es[tol].cost = w; es[tol].next = head[u]; head[u] = tol++; } struct node { int from,to,cost; friend bool operator<( const node&a , const node&b ) { return a.cost<b.cost; } }data[maxm>>1]; int dis[maxn],vis[maxn],used[maxm>>1],pre[maxm>>1],id[maxm>>1],sizes; int Find( int x ) { if ( x!=pre[x] ) pre[x] = Find( pre[x] ); return pre[x]; } void Build( int l , int r ) { for ( int i=l ; i<=r ; i++ ) { pre[data[i].to] = data[i].to; pre[data[i].from] = data[i].from; id[data[i].to] = -1; id[data[i].from] = -1; used[data[i].to] = 0; used[data[i].from] = 0; } for ( int i=l ; i<=r ; i++ ) { int fx = Find( data[i].from ); int fy = Find( data[i].to ); if ( fx!=fy ) pre[fy] = fx; } for ( int i=l ; i<=r ; i++ ) { int fx = Find( data[i].from ); int fy = Find( data[i].to ); if ( !used[data[i].from] ) { if ( id[fx]==-1 ) id[fx] = ++sizes; addedge( data[i].from , id[fx] , 1 ); addedge( id[fx] , data[i].from , 1 ); } if ( !used[data[i].to] ) { if ( id[fy]==-1 ) id[fy] = ++sizes; addedge( data[i].to , id[fy] , 1 ); addedge( id[fy] , data[i].to , 1 ); } } } struct point { int pos,dis; friend bool operator<( const point&a , const point&b ) { return a.dis>b.dis; } }; void dijkstra() { priority_queue<point>Q; for ( int i=1 ; i<=sizes ; i++ ) dis[i] = inf,vis[i] = 0; dis[1] = 0; point p,q; p.pos = 1; p.dis = 0; Q.push(p); while ( !Q.empty() ) { p = Q.top(); Q.pop(); int u = p.pos; if ( vis[u] ) continue; vis[u] = 1; for ( int i=head[u] ; i!=-1 ; i=es[i].next ) { int v = es[i].to,w = es[i].cost; if ( dis[v]>dis[u]+w ) { dis[v] = dis[u]+w; p.pos = v; p.dis = dis[v]; Q.push(p); } } } } int main() { for ( ; scanf ( "%d%d" , &n , &m )==2 ; ) { for ( int i=1 ; i<=m ; i++ ) scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost ); sort ( data+1 , data+m+1 ); tol = 0; sizes = n; memset ( head , -1 , sizeof(head) ); for ( int i=1 ; i<=m ; i++ ) { int l=i,r=i; while ( r+1<=m&&data[r+1].cost==data[i].cost ) r++; Build( l , r ); i = r; } dijkstra(); if ( dis[n]==inf ) dis[n] = -2; printf ( "%d\n" , dis[n]>>1 ); } return 0; }
a.cc:6:18: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 6 | int n,m,tol,head[maxm]; | ^~~~ | maxn a.cc:10:5: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 10 | }es[maxm]; | ^~~~ | maxn a.cc: In function 'void addedge(int, int, int)': a.cc:14:5: error: 'es' was not declared in this scope 14 | es[tol].to = v; | ^~ a.cc:16:20: error: 'head' was not declared in this scope; did you mean 'read'? 16 | es[tol].next = head[u]; | ^~~~ | read a.cc: At global scope: a.cc:27:7: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 27 | }data[maxm>>1]; | ^~~~ | maxn a.cc:29:30: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 29 | int dis[maxn],vis[maxn],used[maxm>>1],pre[maxm>>1],id[maxm>>1],sizes; | ^~~~ | maxn a.cc:29:43: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 29 | int dis[maxn],vis[maxn],used[maxm>>1],pre[maxm>>1],id[maxm>>1],sizes; | ^~~~ | maxn a.cc:29:55: error: 'maxm' was not declared in this scope; did you mean 'maxn'? 29 | int dis[maxn],vis[maxn],used[maxm>>1],pre[maxm>>1],id[maxm>>1],sizes; | ^~~~ | maxn a.cc: In function 'int Find(int)': a.cc:33:13: error: 'pre' was not declared in this scope; did you mean 'pread'? 33 | if ( x!=pre[x] ) | ^~~ | pread a.cc:35:12: error: 'pre' was not declared in this scope; did you mean 'pread'? 35 | return pre[x]; | ^~~ | pread a.cc: In function 'void Build(int, int)': a.cc:42:9: error: 'pre' was not declared in this scope 42 | pre[data[i].to] = data[i].to; | ^~~ a.cc:42:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 42 | pre[data[i].to] = data[i].to; | ^ a.cc:42:31: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 42 | pre[data[i].to] = data[i].to; | ^ a.cc:43:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 43 | pre[data[i].from] = data[i].from; | ^ a.cc:43:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 43 | pre[data[i].from] = data[i].from; | ^ a.cc:44:9: error: 'id' was not declared in this scope; did you mean 'i'? 44 | id[data[i].to] = -1; | ^~ | i a.cc:44:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 44 | id[data[i].to] = -1; | ^ a.cc:45:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 45 | id[data[i].from] = -1; | ^ a.cc:46:9: error: 'used' was not declared in this scope 46 | used[data[i].to] = 0; | ^~~~ a.cc:46:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 46 | used[data[i].to] = 0; | ^ a.cc:47:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 47 | used[data[i].from] = 0; | ^ a.cc:51:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 51 | int fx = Find( data[i].from ); | ^ a.cc:52:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 52 | int fy = Find( data[i].to ); | ^ a.cc:54:13: error: 'pre' was not declared in this scope 54 | pre[fy] = fx; | ^~~ a.cc:58:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 58 | int fx = Find( data[i].from ); | ^ a.cc:59:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 59 | int fy = Find( data[i].to ); | ^ a.cc:60:15: error: 'used' was not declared in this scope 60 | if ( !used[data[i].from] ) | ^~~~ a.cc:60:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 60 | if ( !used[data[i].from] ) | ^ a.cc:62:18: error: 'id' was not declared in this scope; did you mean 'i'? 62 | if ( id[fx]==-1 ) | ^~ | i a.cc:64:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 64 | addedge( data[i].from , id[fx] , 1 ); | ^ a.cc:64:37: error: 'id' was not declared in this scope; did you mean 'i'? 64 | addedge( data[i].from , id[fx] , 1 ); | ^~ | i a.cc:65:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 65 | addedge( id[fx] , data[i].from , 1 ); | ^ a.cc:67:15: error: 'used' was not declared in this scope 67 | if ( !used[data[i].to] ) | ^~~~ a.cc:67:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 67 | if ( !used[data[i].to] ) | ^ a.cc:69:18: error: 'id' was not declared in this scope; did you mean 'i'? 69 | if ( id[fy]==-1 ) | ^~ | i a.cc:71:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 71 | addedge( data[i].to , id[fy] , 1 ); | ^ a.cc:71:35: error: 'id' was not declared in this scope; did you mean 'i'? 71 | addedge( data[i].to , id[fy] , 1 ); | ^~ | i a.cc:72:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 72 | addedge( id[fy] , data[i].to , 1 ); | ^ a.cc: In function 'void dijkstra()': a.cc:104:21: error: 'head' was not declared in this scope; did you mean 'read'? 104 | for ( int i=head[u] ; i!=-1 ; i=es[i].next ) | ^~~~ | read a.cc:104:41: error: 'es' was not declared in this scope 104 | for ( int i=head[u] ; i!=-1 ; i=es[i].next ) | ^~ a.cc:107:32: error: 'w' was not declared in this scope 107 | if ( dis[v]>dis[u]+w ) | ^ a.cc: In function 'int main()': a.cc:123:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 123 | scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost ); | ^ a.cc:123:53: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 123 | scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost ); | ^ a.cc:123:67: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 123 | scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost ); | ^ a.cc:124:20: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+' 124 | sort ( data+1 , data+m+1 ); | ~~~~^~ a.cc:124:29: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+' 124 | sort ( data+1 , data+m+1 ); | ~~~~^~ a.cc:127:18: error: 'head' was not declared in this scope; did you mean 'read'? 127 | memset ( head , -1 , sizeof(head) ); | ^~~~ | read a.cc:131:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 131 | while ( r+1<=m&&data[r+1].cost==data[i].cost ) | ^ a.cc:131:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 131 | while ( r+1<=m&&data[r+1].cost==data[i].cost ) | ^
s626442573
p04003
C++
#include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<queue> #define MAXN 500000 #define INF 0x3FFFFFFF using namespace std; struct edge { int u,v,w; edge(){}; edge(int _u,int _v,int _w):u(_u),v(_v),w(_w){}; }; struct state { int u,dist; state(){}; state(int _u,int _dist):u(_u),dist(_dist){}; }; bool operator < (edge a,edge b){return a.w<b.w;} bool operator < (state a,state b){return a.dist<b.dist;} priority_queue<state> que; vector<edge> edges; vector<int> G[MAXN+5]; vector<int> need; int setfa[MAXN+5],imcnt,img[MAXN+5],dist[MAXN+5]; bool vis[MAXN+5]; void Init1() { for(int i=0;i<=MAXN;i++) setfa[i]=i; } void Init(int N) { if(imcnt==0) for(int i=0;i<=MAXN;i++) dist[i]=INF,G[i].clear(); else for(int i=0;i<=imcnt;i++) dist[i]=INF,G[i].clear(); edges.clear(); imcnt=N; } inline int Findfa(int x) { if(x==setfa[x]) return x; return setfa[x]=Findfa(setfa[x]); } inline void Union(int x,int y) { int fx=Findfa(x),fy=Findfa(y); if(fx==fy) return; setfa[fx]=fy; } inline void Set(int x) { if(vis[x]==true) return; vis[x]=true; img[x]=++imcnt; } int Dijkstra(int ed) { while(que.empty()==false) que.pop(); que.push(state(1,0)); dist[1]=0; while(que.empty()==false) { int u=que.top().u; int dn=que.top().dist; que.pop(); if(dist[u]!=dn) continue; if(u==ed) return dn; for(int i=0;i<(int)G[u].size();i++) { int v=G[u][i]; if(dist[v]>dn+1) { dist[v]=dn+1; que.push(state(v,dist[v])); } } } } inline read() { char c=0; int ret=0; while(c<'0'||c>'9') c=getchar(); ret=c-'0'; while(true) { c=getchar(); if(c<'0'||c>'9') break; else ret=10*ret+c-'0'; } return ret; } int main() { int N,M; Init1(); scanf("%d %d",&N,&M); Init(N); int a,b,c; for(int i=1;i<=M;i++) { a=read(),b=read(),c=read(); edges.push_back(edge(a,b,c)); Union(a,b); } if(Findfa(1)!=Findfa(N)) { printf("-1\n"); return 0; } for(int i=0;i<=N;i++) setfa[i]=i; sort(edges.begin(),edges.end()); for(int i=0;i<=(int)edges.size();i++) { if(i==(int)edges.size()||(i!=0&&edges[i].w!=edges[i-1].w)) { for(int j=0;j<(int)need.size();j++) { Set(Findfa(need[j])); img[need[j]]=img[Findfa(need[j])]; G[need[j]].push_back(img[need[j]]); G[img[need[j]]].push_back(need[j]); } for(int j=0;j<(int)need.size();j++) vis[need[j]]=false,setfa[need[j]]=need[j]; need.clear(); } if(i<(int)edges.size()) { need.push_back(edges[i].u); need.push_back(edges[i].v); Union(edges[i].u,edges[i].v); } } int ans=Dijkstra(N); printf("%d\n",ans/2); // } return 0; }
a.cc:90:8: error: ISO C++ forbids declaration of 'read' with no type [-fpermissive] 90 | inline read() | ^~~~ a.cc: In function 'int Dijkstra(int)': a.cc:89:1: warning: control reaches end of non-void function [-Wreturn-type] 89 | } | ^
s186332567
p04003
C++
#include<iostream> #include<cstdio> #include<vector> #include<queue> #include<cstring> using namespace std; int pa[111111],id[111111],cnt,rank[111111]; bool used[111111]; int n,m,x,y,z; vector<pair<int,int> > g[1111111]; vector<int> gra[1111111]; void Init(int i) { pa[i]=i; used[i]=0; id[i]=-1; rank[i]=1; } int root(int x) { if (pa[x]!=x) pa[x]=root(pa[x]); return pa[x]; } void Union(int x,int y) { int rx=root(x),ry=root(y); if (rx==ry) return; if (rank[rx]>rank[ry]) { pa[ry]=rx; rank[rx]+=rank[ry]; } else { pa[rx]=ry; rank[ry]+=rank[rx]; } } queue<int> q; int dist[1111111]; void write(int x) { if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } int main() { while(scanf("%d%d",&n,&m)!=-1) { for (int i=1;i<=n;i++) g[i].clear(); for (int i=1;i<=1000000;i++) gra[i].clear(); for (int i=1;i<=m;i++) { scanf("%d%d%d",&x,&y,&z); g[z].push_back(make_pair(x,y)); } cnt=n; for (int i=1;i<=1000000;i++) { for (int j=0;j<g[i].size();j++) { Init(g[i][j].first); Init(g[i][j].second); } for (int j=0;j<g[i].size();j++) { Union(g[i][j].first,g[i][j].second); } for (int j=0;j<g[i].size();j++) { x=g[i][j].first;y=g[i][j].second; if (!used[x]) { int r=root(x); if (!~id[r]) id[r]=++cnt; used[x]=1; gra[x].push_back(id[r]); gra[id[r]].push_back(x); } if (!used[y]) { int r=root(y); if (!~id[r]) id[r]=++cnt; used[y]=1; gra[y].push_back(id[r]); gra[id[r]].push_back(y); } } } memset(dist,-1,sizeof(dist)); q.push(1);dist[1]=0; while(!q.empty()) { x=q.front();q.pop(); for (int i=0;i<gra[x].size();i++) { int to=gra[x][i]; if (!~dist[to]) { dist[to]=dist[x]+1; q.push(to); } } } if (!~dist[n]) printf("-1\n"); else printf("%d\n",dist[n]/2); } return 0; }
a.cc: In function 'void Init(int)': a.cc:17:9: error: reference to 'rank' is ambiguous 17 | rank[i]=1; | ^~~~ 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:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:28:13: error: reference to 'rank' is ambiguous 28 | if (rank[rx]>rank[ry]) | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc:28:22: error: reference to 'rank' is ambiguous 28 | if (rank[rx]>rank[ry]) | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc:31:17: error: reference to 'rank' is ambiguous 31 | rank[rx]+=rank[ry]; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc:31:27: error: reference to 'rank' is ambiguous 31 | rank[rx]+=rank[ry]; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc:36:17: error: reference to 'rank' is ambiguous 36 | rank[ry]+=rank[rx]; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~ a.cc:36:27: error: reference to 'rank' is ambiguous 36 | rank[ry]+=rank[rx]; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:31: note: 'int rank [111111]' 7 | int pa[111111],id[111111],cnt,rank[111111]; | ^~~~
s462657074
p04003
C++
#include<bits/stdc++.h> using namespace std; vector<pair<int,int> > nei[1000005]; vector<int> cit[1000005]; vector<int>comp; int col[1000005]; bool vis[1000005]; vector<int>newnei[1000005]; int dp[1000005]; int poi[1000005]; queue<int> q; //无需跑最短路,直接写bfs,用queue int main() { int n,m; cin>>n>>m; memset(col,-1,sizeof col); for(int i=0;i<m;i++) { int x,y,c; scanf("%d %d %d",&x,&y,&c); x--,y--,c--; nei[x].push_back(make_pair(c,y)); nei[y].push_back(make_pair(c,x)); cit[c].push_back(x); cit[c].push_back(y); comp.push_back(c); } sort(comp.begin(),comp.end()); comp.erase(unique(comp.begin(),comp.end()),comp.end()); for(int i=0;i<n;i++) { sort(nei[i].begin(),nei[i].end()); } int newci=n; for(int i=0;i<comp.size();i++) { int cmp=comp[i]; for(int j=0;j<cit[comp[i]].size();j++) { int v=cit[comp[i]][j]; if(col[v]==cmp) continue; q.push(v); col[v]=cmp; vector<int> ciin; while(!q.empty()) { v=q.front(); ciin.push_back(v); q.pop(); int k=0; for(;poi[v]<nei[v].size();poi[v]++) //这里的poi[v]很好的利用了按公司编号从小到大的单调性 { k=poi[v]; if(nei[v][k].first!=cmp) break; int u=nei[v][k].second; if(col[u]==cmp) continue; col[u]=cmp; q.push(u); } } for(int k=0;k<ciin.size();k++) { int v=ciin[k]; newnei[v].push_back(newci); newnei[newci].push_back(v); } newci++; } } for(int i=0;i<newci;i++) dp[i]=-2; dp[0]=1; q.push(0); while(!q.empty()) { int v=q.front(); q.pop(); for(int k=0;k<newnei[v].size();k++) { int u=newnei[v][k]; if(dp[u]==-2) { dp[u]=dp[v]+1;q.push(u); } } } cout<<dp[n-1]/2; }#include<bits/stdc++.h> using namespace std; vector<pair<int,int> > nei[1000005]; vector<int> cit[1000005]; vector<int>comp; int col[1000005]; bool vis[1000005]; vector<int>newnei[1000005]; int dp[1000005]; int poi[1000005]; queue<int> q; //无需跑最短路,直接写bfs,用queue int main() { int n,m; cin>>n>>m; memset(col,-1,sizeof col); for(int i=0;i<m;i++) { int x,y,c; scanf("%d %d %d",&x,&y,&c); x--,y--,c--; nei[x].push_back(make_pair(c,y)); nei[y].push_back(make_pair(c,x)); cit[c].push_back(x); cit[c].push_back(y); comp.push_back(c); } sort(comp.begin(),comp.end()); comp.erase(unique(comp.begin(),comp.end()),comp.end()); for(int i=0;i<n;i++) { sort(nei[i].begin(),nei[i].end()); } int newci=n; for(int i=0;i<comp.size();i++) { int cmp=comp[i]; for(int j=0;j<cit[comp[i]].size();j++) { int v=cit[comp[i]][j]; if(col[v]==cmp) continue; q.push(v); col[v]=cmp; vector<int> ciin; while(!q.empty()) { v=q.front(); ciin.push_back(v); q.pop(); int k=0; for(;poi[v]<nei[v].size();poi[v]++) //这里的poi[v]很好的利用了按公司编号从小到大的单调性 { k=poi[v]; if(nei[v][k].first!=cmp) break; int u=nei[v][k].second; if(col[u]==cmp) continue; col[u]=cmp; q.push(u); } } for(int k=0;k<ciin.size();k++) { int v=ciin[k]; newnei[v].push_back(newci); newnei[newci].push_back(v); } newci++; } } for(int i=0;i<newci;i++) dp[i]=-2; dp[0]=1; q.push(0); while(!q.empty()) { int v=q.front(); q.pop(); for(int k=0;k<newnei[v].size();k++) { int u=newnei[v][k]; if(dp[u]==-2) { dp[u]=dp[v]+1;q.push(u); } } } cout<<dp[n-1]/2; }
a.cc:88:3: error: stray '#' in program 88 | }#include<bits/stdc++.h> | ^ a.cc:88:4: error: 'include' does not name a type 88 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:90:24: error: redefinition of 'std::vector<std::pair<int, int> > nei [1000005]' 90 | vector<pair<int,int> > nei[1000005]; | ^~~ a.cc:3:24: note: 'std::vector<std::pair<int, int> > nei [1000005]' previously declared here 3 | vector<pair<int,int> > nei[1000005]; | ^~~ a.cc:91:13: error: redefinition of 'std::vector<int> cit [1000005]' 91 | vector<int> cit[1000005]; | ^~~ a.cc:4:13: note: 'std::vector<int> cit [1000005]' previously declared here 4 | vector<int> cit[1000005]; | ^~~ a.cc:92:12: error: redefinition of 'std::vector<int> comp' 92 | vector<int>comp; | ^~~~ a.cc:5:12: note: 'std::vector<int> comp' previously declared here 5 | vector<int>comp; | ^~~~ a.cc:93:5: error: redefinition of 'int col [1000005]' 93 | int col[1000005]; | ^~~ a.cc:6:5: note: 'int col [1000005]' previously declared here 6 | int col[1000005]; | ^~~ a.cc:94:6: error: redefinition of 'bool vis [1000005]' 94 | bool vis[1000005]; | ^~~ a.cc:7:6: note: 'bool vis [1000005]' previously declared here 7 | bool vis[1000005]; | ^~~ a.cc:95:12: error: redefinition of 'std::vector<int> newnei [1000005]' 95 | vector<int>newnei[1000005]; | ^~~~~~ a.cc:8:12: note: 'std::vector<int> newnei [1000005]' previously declared here 8 | vector<int>newnei[1000005]; | ^~~~~~ a.cc:96:5: error: redefinition of 'int dp [1000005]' 96 | int dp[1000005]; | ^~ a.cc:9:5: note: 'int dp [1000005]' previously declared here 9 | int dp[1000005]; | ^~ a.cc:97:6: error: redefinition of 'int poi [1000005]' 97 | int poi[1000005]; | ^~~ a.cc:10:6: note: 'int poi [1000005]' previously declared here 10 | int poi[1000005]; | ^~~ a.cc:98:13: error: redefinition of 'std::queue<int> q' 98 | queue<int> q; //无需跑最短路,直接写bfs,用queue | ^ a.cc:11:13: note: 'std::queue<int> q' previously declared here 11 | queue<int> q; //无需跑最短路,直接写bfs,用queue | ^ a.cc:99:6: error: redefinition of 'int main()' 99 | int main() | ^~~~ a.cc:12:6: note: 'int main()' previously defined here 12 | int main() | ^~~~
s692893508
p04003
C++
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int inf = 2e9; int n, m; vector<int> adj[N], col[N], imp[N]; vector<int> f[N]; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= m; ++i) { int u, v, c; cin >> u >> v >> c; col[u].push_back(c), col[v].push_back(c); imp[u].push_back(adj[v].size()), imp[v].push_back(adj[u].size()); adj[u].push_back(v), adj[v].push_back(u); } for (int i = 1; i <= n; ++i) { f[i].assign(adj[i].size(), (i == 1 ? 1 : inf)); } priority_queue<pair<int, pair<int,int> > , vector<pair<int, pair<int,int> > >, greater<pair<int, pair<int,int> > > > pq; for (int i = 0; i < adj[1].size(); ++i) pq.push({1, {1, i}}); while (!pq.empty()) { auto cur = pq.top(); pq.pop(); int u = cur.second.first, id = cur.second.second; if (f[u][id] != cur.first) continue; if (u == n) return cout << f[u][id] << '\n'; for (int i = 0; i < adj[u].size(); ++i) { int nu = adj[u][i], nid = imp[u][i]; int add = 1; if (col[u][id] == col[nu][nid]) add = 0; if (f[nu][nid] > f[u][id] + add) { f[nu][nid] = f[u][id] + add; pq.push({f[nu][nid], {nu, nid}}); } } } cout << -1 << '\n'; }
a.cc: In function 'int main()': a.cc:32:53: error: cannot convert 'std::basic_ostream<char>' to 'int' in return 32 | if (u == n) return cout << f[u][id] << '\n'; | ~~~~~~~~~~~~~~~~~^~~~~~~ | | | std::basic_ostream<char>
s546913171
p04003
C++
#include <bits/stdc++.h> #include <time.h> #include <tr1/unordered_map> #include <tr1/unordered_set> #include <unordered_map> using namespace std::tr1; using namespace std; /* cau troi cho Garena nhap de con Bach */ #define FSYNC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define fi first #define se second #define cur fi.fi #define com fi.se #define val se #define pb push_back #define mp make_pair #define int long long #define endl '\n' #define inf 0x3f3f3f3f #define lb lower_bound #define pob pop_back #define ub upper_bound #define ite ::iterator #define db(x) {cout <<"#db " << x << endl;} #define here() {cout <<"here \n";} #define mod 1000000007 typedef pair<int,int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; const int MOD = 1e9 + 7; const int _MOD = 998244353; const int N = 1e5 + 2; int fpow(int x,int y) {int res=1;while(y){if(y&1)res=res*x%MOD;x=x*x%MOD;y>>=1;}return res;} int inverse(int x){return fpow(x,MOD-2);} int n, m; vii g[N]; unordered_map<ii,int> lead; int leadcnt = 0; int state[4*N]; queue<pair<ii,int> >q; int ans = inf; // cur - comp - val signed main(){ scanf("%lld%lld",&n,&m); for(int i = 0 ; i < m ; i ++){ int u,v,c;cin >> u >> v >> c; g[u].pb(mp(v,c)); g[v].pb(mp(u,c)); } for(int i = 0 ; i < 4*N ; i ++) state[i] = inf; q.push(mp(mp(1,0),0)); lead[ii(1,0)] = ++leadcnt;state[1] = 0; while(q.size()){ int u = q.front().cur; int comp = q.front().com; int low = q.front().val; q.pop(); if(low > state[lead[ii(u,comp)]]) continue; if(u == n){ if(low < ans) ans = low; continue; } for(ii v:g[u]){ if(!lead[ii(v.fi,v.se)]){ lead[ii(v.fi,v.se)] = ++leadcnt; state[leadcnt] = low + (v.se != comp); q.push(mp(v,low + (v.se != comp))); }else{ if(low + (v.se != comp) < state[lead[v]]){ state[lead[v]] = low + (v.se != comp); q.push(mp(v,low + (v.se != comp))); } } } } if(ans != inf) cout << ans; else cout << -1; return 0; }
a.cc:40:1: error: reference to 'unordered_map' is ambiguous 40 | unordered_map<ii,int> lead; | ^~~~~~~~~~~~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:109:11: note: candidates are: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map' 109 | class unordered_map | ^~~~~~~~~~~~~ In file included from /usr/include/c++/14/tr1/unordered_map:44, from a.cc:3: /usr/include/c++/14/tr1/unordered_map.h:180:11: note: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::tr1::unordered_map' 180 | class unordered_map | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:55:9: error: 'lead' was not declared in this scope; did you mean 'read'? 55 | lead[ii(1,0)] = ++leadcnt;state[1] = 0; | ^~~~ | read
s296137589
p04003
C++
/* ID:njbxgub1 PROB:Shuke's Subway Trip LANG:C++ */ /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . ___ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ·e×?±£óó óà?TBUG */ /* .:: ,, .: :, :. :LuqL 5B@ :v 77L21F5F5F5F1F5S15Uv7, :@B 0@U .B@ L@P B@B@@@B@B@B@@B L@B B@B@, @BB2XSPSPkPXPkPXPF2B@B .@B@B@B@B@@@B@B@B@B@@@B@B@B@B@B@ :@@@@BBMOB@BGM@B@BME@@@EMB@B@B@r ,Yi: @B2 iB@ 2@@@7 B@, 8Bq vriii:.:0@@:ii::,:::B@B::iiii77 ,E1uJuJJ7GB@7LUk2ULvB@B7LjJjjSq: B@7 @B i7 @B@B@B@B@B@B@B@B@B@B@k @B .BZ u@. : ,@N 7B2 0EqEqX2@B@1N0Z0ZSqB@qX0ZNPUYLSZ8 B@ NBP :@B 1@BMX0uj2EEZN15, 8@B@B@@@GGB@7 5@B@BOM@B@B@B. @B@B@B@@@B@B@B@B@B@B@B@B@B@B@B@B @B@B@B@B@B@B@B@B@B@B@q @B@B@B@B@@@u S@B2qOOMOMM@BMB@L @@7 B@. @Bv @@v . B@: k@v :i;.,...q5::B@k @Bi 8@@B@B@B@B@v BB@B@B@B@@@B. B@L .,7 0B@ SB@S :5jj7vi::iiiii:..,:iii::;77LY25 B@ @B u@20B@B@B@B@N @@: B@ .: B@ :: .:v28P@B@@@B@B@, ,@@ u@B@. YB@B@ME0OB@B@@@B@BMB@B@BBOBB@B@. L@@ OBS B@: JB@ @B. v@BLuXP0qXvL: 1@B7ukXE00SYvL @@@B@B@B@Z. B@kLB@B: 7Ei @@; @B: B@ @B .@O B@ LO1i , @B0 ;BX7. ,..P@B @Bu 1B@B5 :: :@B B@@@B@B@@@B@B@ 7@@ U@u B@i,::.PB@ @B .7OBGu Z@v rNBOFi 7B8 B@5 7B@B@B@ B@B i@B@7 @BN.::i:i:i:ii 17 @B @B@B@B@MMY B@ u@OBUMBi :@BNBYv@F @B0 u@B@B@L kB@; @@; 0@B.J@@O: B@i ,:ii7@B@B@@@u SZ i@B LB@@@B@5Y, B@, 5@@@B@GFY: ZBu :5rr:5B@J MBM: iB@@k:@@@ ,NB@E k@@B@B@B@qEZMMBM@MBB@Br @B@B@OY77:, :MSUjuukB@Br iBvUr. .8@B i5::r YB@ .B@B@BZ: 0B@B8 @BO .:i:77uU5uFSkFkFXXq B@B@@@GU. ,@B@B@BM: B@B@B@B7 .:7kq ;@B, , @B. i@M .B@, N@@ .BO :,. .:.. LB@@@B@B@B@B@@ :B@, EB@O, B@i U@@ ,q@BX 1@B ,q@B0: ,B@B@B@B@B@B@1 @B@B@B@B@B@B@ kri. M@@ @B: u@B@J @B@B@B@B@@@Bi J@@@B@B@B@B@B irrvi:u@BjLJ7@B@7YYLB@Bj::rir @Bj i@B EBO @@: :1 iiii:i::,:B@: uB@.::i:i:iii @B@qquvrLu1127rrUU5Uvrrv5q@B@. .,iiiii::B@L .,:iiiii:E@@ YLLvv7iB@Bi7YLYL7r@@ErLLL7r::iYU @@i Y@@ B@k . . ... @B, B@B@B@B@B@BF @B@B@B@B@@@B @@B@B@B@B@@@B@B@B@B@B@B@B@B@B@B@. B@i uB@ r7. ,B@MMMBMBMBMBMBMMG@B@ 7v r@M LB8 E@O PBM . vB@B@B@@@B@Bi J@B@B@B@B@@@7 .@B P@8 @BX.::i:i: B@2,:::i:i. . Z@M ; ;@B i@@@ ,ULYLJLL77@@i uB@ivLYLJLJu: ,B@B@B@B@B@B@B@B@B@B@ BOEOB@B@B@B@q BZNO@B@B@B@B@@ ,:i7JB@B@B@B@@u B@: :B@Bv @Bi J@B 2J uB@ :u: @@r @BL 7@X: 8BZ B@B@B@B@B@,i. kBBi@B@L B@i j@@ uYjvJ2kSk1jM@@u2kFS1uLuJUi iu@B@O B@i .iNB@Bj B@u . Z@M :@B@Mi : rEXqXXXPS5U@Bi Y@Bj1XXqkXXN07 B@Bq088OOGk@B@SE8OZZNq5@B@ i7:, @@, ::i2r @B7 MB@ ,8B@B@B kB@ Y@@B@B@BBOGB@i uB@EMB@B@B@B@j @Bi 7@B G@8 ukBB@@@B@P B@ .75BB@@@B@: B@: O@B 7u@B@BO, v@@v B@G @Bi J@B B@Y uB@ 7:,.i@BS ,B@B1: .@B N@@BL @B. 5ri:r@B@ k@BL. ,@B@q:5@B B@r 1@@ @B7 F@B @B@B@Or .i.,,:1@B8 r,:::u@B@ @B@B@B1 .q@B@B: @Br L@B 5B@ kB@B@@@5. r@@@@B@Z; ,ijN B@L . B@5 .:...,:,:,. ,,:....... ... . :@B@B@@@B@B@@@i @B1 j@B@. .@B .B@B@B@@@B@B@B@B@B G@B@B@B@B@B@B .B@B@B@@@B@B@v 7;L7ri. @@@B@B@@ B@B@B@@@B@B@@ NLrr:0B@ B@2 YB@@N UBB ... . .@B@Bi B@ @Br B@BBB@8 B@ JBE :B@ :@B BBk .O: E@B@B@B@B@B@P .M@BS ..,:,:,.7@@ ,.:,:::.,B@i @B :BS BB B@ @B :L77rr:E@@ir7vvvr:B@B:rv7ri:::rJ :7ij@Biir:@BM :@B@i v@B@@@B@B@@@ UB@B@B@B@B@BL B@ i@5 M@ S@v UB@B@@M B@ 8B@B@B@B@B@B@B@B@B@@@B@B@@@B@B@@L JBM @@i 5B@ @B. @@ @B ;@F BB @B O@L .@B @B 7B@ i@B @@, @B L@B ,B@..,:,,.. :@B..,,:,:. . B@ i@5 M@ .B@ NB. B@ @@ ;@B ,, B@ @@B. U@B 0BE @B@B@B@B@B@B@B@B@B@ LBEOB@@@B@B@B UO0G@B@B@B@B@Bi @B rBS MB. :@@ X@, @B @B ,;7B@@B@B@B@B @B5 MB@q @B7 B@ Y@B :@5. B@ OOv @@ B@ i@5 M@. jB5 kB. B@ B@ 7B@B@B@B@@1r: ;@B.Z@@O iB@@r B@j vB@ ,1@B@B; :@B i0B@B@ @B @B ,BF MB. @B 2@5i7@B @B :: 7B@ B@B@u 7@B@B Y@@ j , r@@ i :0 ,B@ B@LLG@F M@ @@ 0@@B@MZ B@ L@B v@B@@@: :@B: B@B@B1. jB@ :LLkBB@B@B 7@B :7L0@B@@@B :@@ @@MO@BO BB2B@B@7 Y@ @@ 7B@ .7B@B@B7 :B@u qB@ .@B@ .@B@: 7@B O@@B7, BBO B@BMi SB@ B@ : B@.:i: B@ u::.,B@B LB@Gi .B@B2.:B@i uB@B7 rL::,:@B@ :. ,P@@: :, .:uB@r @B. .:. U@@ B@B@BBS 5B@BM: MB v@@@@@Mv @@B@B@Bv B@@@B@Bu M@ .@B@B@X */ /* UM. J@B@1 iO@1 Y@@@B@BB. 7B@B@B@ :@B@i,B@B@O ,Z@B@B@B@Br @B@q i@B@BS 7@B@@@O5vMB@q 8@@B LB@B@i FB@@@BNjYjLE@B@ ,B@B: 0@@@Z P@B@BM1JJ125JPB@B B@BB :@B@B XB@B@Z2LuU52F2u2@B@. :@B@ @@@B: v@B@B8uJj51F1525uUB@B7 @B@O 0@@B. ..::ir7vvYUuU777r::. B@B@OULU2F2F151F11Y@B@S B@B, 8B@B :ruXMB@B@B@B@B@B@B@B@B@B@@@B@B@B@B@B@B@5Jj1211F1F1F2FUJO@BB U@B@ @B@B@B@B@B@@@B@B@B@MMqPS5JuYL7rq@B@OBB@B@B8Yu211F1515251515YGB@@ @B@u v@@@@MSur:. LB@MvvjJuU5YU252F1F1F25251F2uX@@@ @@@. N@BML2U2UUU12F15252525251515Jk@@B r@B@ YB@Bju52121252515252F15251F2u5@B@ PB@B @@@PYUF151F25151F152F2F1F15jF@@B @@BS N@@@UJ2F25252F251525151F1F1u5@B@ @@@7 B@B@5Yj12F152F1F1F25252515jFB@B B@Bi M@B@O2Luu52525212F151121UY1@B@7 O@B@: v@B@BMSuYJJuuUu2u2uujjYJJXB@B@M 7B@B@, 1B@@@B@GPF1uujuu21PNMB@B@B@B@@ qB@B2 i8B@B@B@B@B@@@@@B@B@B@q: @@@B MB@B: 7SBB@B@B@B@B@Zu: @B@B ZB@B. ,v. @B@L LB@B, Y7 @B@Bu 7@B@ :B@B@@B2: @@B7 @B@Z r@B@B@BP: B@BE BB@@@B@B@B@BE r@B@B 7@B@B@B@Ou: iB@B :uM@@B@@2. :7::::ivk@B@B@0 :5B@B@B@B@B@B@G. @B@i BB@@@B@@ :@B@B@@@B@B@@1 .i5M@B@B@@@5 M@@2 B@B ,@B1 L0EZZG0F7: .:, uB@MrP@M7 2@B@ ,O@B@B@B@B @B@1 :@B@@@r :@@@@B@BL:,, B@Bi :2ZS; :@B@B@B@r L@B@B@BU @B@. @@@B@B@ vB@B@B@B5 @B@i B@B 7B@B@B@BM OB@B@B@ ,B@B @B@ @B@B@@@i rL7. B@BM B@B7.: NB@@M. .@B@. .;JEB@@@B@B@B@B@. . @B@u @@@B@B@B@B@@@B@18U :B@B@B@BU, 7@BOui. ,@@B SP@B@B@B@B@Or @@@U B@BJ.YO@B@B@i r@B@ :B@Bk .k@B@ B@B@ LB@@k 2i B@BM .7jXEGqF7: OB@@L .B@BM .B@B@B@B@B@B@. :@B@B: .B@B@ @@MYr::ivG@B .M@B@G B@@@S ,MB@B@, v@@@BF .1B@B@Br 2@@B@BL ,FB@@@B8, r@B@B@BF, :YBB@B@B@B L@B@B@B@P7, .ivXB@B@B@B@B@M@B@ ,1B@B@B@B@@@BOP2L7i:,. ..,:i7LSNB@@B@B@@@B@B@B@Z5v;.LB@@ @B@OEB@B@@@B@B@B@B@B@B@B@B@@@B@B@B@B@B@@@B@B@B@B@BM0SJ7i::::i:,u@B@ B@Bu ::i;7vu2XNGOMB@B@BMB@B@B@B@B@B@@@B1UFuj77ii:::::::iir;r;i.YB@B @B@L.:i:i:i::::::::::..Y@B@BMYi:i;SB@B@N:.::i:iirir;r;rii::::ivO@B@ B@@X::,::::iirir;riri:E@B@1 ,@B@Br:;;r;rii:i::::i7JEB@@@@@B @@@B@BBq5v7ii:::::::.2@@@i ..,.. @B@@,,:::::irv2XMB@B@B@B@2@B@: .B@BBB@@@B@B@B@BMNP5u7@B@1 .,,:,, :. @B@P50MB@B@B@B@B@@@BS: @@B1 E@B@ ijGB@B@B@B@B@B@B@Bi .,:,,..@@B@7 B@B@B@B@B@B@BM57. kB@B .@B@: .,ivu5Nq@B@u ..,.. SB@B@@@B@PL7i, ,@B@ @@@8 i@B@: . :B@B@@ B@@2 i@@@@ 0@B@u B@@B. vB@B ,@B@G L@B@BOv:.:iFB@B@M @B@Bi vNi S@@B@B@B@B@BM: MB@N 758BMqJ, . YO. vq :G Z: SqOMBB@B@Br @@r rBE @B B@@@@@B@ONX8k i::::.OB1.:::.u@O.::::i @B@B@U:@@B@@BPEBu B@@NB@k. 5@i uB@E. BM 1U2uUJvirB@@Z r@@B@B@@@B@B@B@B@B@@@B@Bi LB@B@1 BX :@k uLLLvr@BJ: iB iBi 7@ .@M8@BGMZZ @@F ,B Pi v@ Bq @i v@ B@ vuL7r8@S7vJL7N@Z7LLri;72. F7@Bvvv@@ @BX @@@B@B@@@@@B@@@B@B@B 7@ @F Bi @q @B@Bu @B N@B@G@@@8@BBOMB@G@BMNXG@, B@ @@ .Bk .:u; i@: Zv 7@ Bk @,;@ ,BY @B B@ r@ @G 5. ,@v BZ :::,.r@E .::i, @B B@ .@BL 7@ @F B:i@. .@ @M @B 7B: ,vO, @@ iB@: @B 7@:MB@B@B@@@B@B@BM @@. B: 2@q 7@ BS @i 0@ B. @O B@ ,r2EBB@B@B@Bi G@ @BB B@ @B @S : r@ .. 7B @F @7 B7 @ @B @B E@B@UOBr @B@Bi L@0PB .BZ .@B@B@B@B@B@B@B@B@B@B@B@, r@ BF @i @G B@B@B B@ 7@, kB@U ;r @@@. .@Z GBuL@iBBi vB@B@q BP:5@7 @u,. @B LBi YB@BrB@ @@ @B:L@Br BM .M@B rB rB@J v@. Pi @XZ8r . B@ . G@i B@BM. ,B@, @B iB@B N, 7r..q@k ,LB@B8 J@, i@B@B1r Br @@ MB@B@B ,i B@B@B, B@: @B@B@F .@BB: P@i :OBZ .@U B@B@B: .ll rB. : *//////////////////// //******************/ //* I<3 C++ */ //* I WANT ANY AC */ //* I LOVE PROGRAM!*/ //*IT'S INTERESTING*/ //* I LOVE PROGRAM!*/ //* IN CONTESTS */ //* GET SCORE */ //* AC CODE */ //* LET'S */ //* GO */ //* Written by: */ //* gbc */ //******************/ ///////////////////// #include <bits/stdc++.h> using namespace std; /*-------------------------------main part------------------*/ #define fro for #define itn int #define mp make_pair #define pb push_back #define on first #define tw second #define be(n) n.begin() #define en(n) n.end() #define all(n) (n.begin(),n.end()) #define PI 3.141592653 #define son(n) int lf=2*n,ri=2*n+1 #define pr int prime[]={0,2,3,5,7,11,13,17,19,23,29,31,37} #define sz(n) n.size() #define big int maxi=-1 #define small int mini=1e9+7 #define op(x) freopen(x,"r",stdin) #define wr(x) freopen(x,"w",stdout) typedef long long ll; typedef pair<int,int> pii; typedef pair<int,pair<int,int> > pipi; typedef vector<int> vi; typedef map<int,int> mii; typedef map<string,int> msi; typedef set<int> jihe; typedef queue<int> qi; typedef vector<pair<int,int> > vp; const int inf=1e9+7; const int maxn=100005; const int maxm=200005; struct st{ int p,b,c; }; int n,m; unordered_map<int,vector<int> > e[maxn]; vector<int> g[maxn]; unordered_map<int,itn> d[maxn]; /*---------------------------declare * function-------------*/ bool operator<(const st &a,const st &b) { return a.c>b.c; } /*---------------------------function * main----------------*/ int main() { ios_base::sync_with_stdio(false); cin>>n>>m; for(int i=1;i<=m;i++) { int p,q,c; cin>>p>>q>>c; e[p][c].pb(q);e[q][c].pb(p); g[p].pb(c);g[q].pb(c); } priority_queue<st> q; d[0][0]=0; q.push({0,0,0}); while(!q.empty()) { st p=q.top(); q.pop(); if(d[p.p][p.b]!=p.c) continue; if(d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c) { d[p.p][0]=p.c; q.push({p.p,0,p.c}); } if(p.b==0) { for(int v=0;v<g[p.p].size();v++) { if(d[p.p].find(v)==d[p.p].end() || d[p.p][v]>p.c+1) { d[p.p][v]=p.c+1; q.push({p.p,v,p.c+1}); } } continue; } fro(int v=0;v<e[p.p][p.b].size();v++) { if(d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){ d[v][p.b]=p.c; q.push({v,p.b,p.c}); } } } small; for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) { mini=min(mini,p->second); } if(mini==inf) { cout<<-1<<endl; } else { cout<<mini<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:268:50: error: conversion from 'std::unordered_map<int, int>::iterator' {aka 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to non-scalar type 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} requested 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ~~~~~~~~~~~~^~ a.cc:268:54: error: no match for 'operator!=' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'std::unordered_map<int, int>::iterator' {aka 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'}) 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ~^~~~~~~~~~~~~~ | | | | | std::unordered_map<int, int>::iterator {aka std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator} | std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator} 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:174: /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::unordered_map<int, int>::iterator' {aka 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::unordered_map<int, int>::iterator' {aka 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ /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:268:67: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 268 | for(map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) | ^ 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 argum
s482823032
p04003
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <unordered_map> #include <deque> #define inf 0x3F3F3F3F using namespace std; struct Node { int x,c; }; deque<Node>q; unordered_map<int,vector<int> >e[100005]; unordered_map<int,int>d[100005]; vector<int>g[100005]; int main(void) { int i,x,y,c,cost,n,m,ans=inf; scanf("%d%d",&n,&m); for(i=1;i<=m;++i) { scanf("%d%d%d",&x,&y,&c); e[x][c].push_back(y); e[y][c].push_back(x); g[x].push_back(c); g[y].push_back(c); } d[0][0]=0;q.push_back((Node){1,0}); while(!q.empty()) { x=q.front().x;c=q.front().c;cost=d[x][c];q.pop_front(); if(d[x].find(0)==d[x].end()||d[x][0]>cost) { d[x][0]=cost;q.push_front((Node){x,0}); } if(c==0) { for(i=1;i<g[x].size();++i) { y=g[x][i]; if(d[x].find(y)==d[x].end()||d[x][y]>cost+1) { d[x][y]=cost+1;q.push_back((Node){x,y}); } } continue; } for(i=0;i<e[x][c].size;++i) { y=e[x][c][i]; if(d[y].find(c)==d[y].end()||d[y][c]>cost) { d[y][c]=cost;q.push_front((Node){y,c}); } } } unordered_map<int,int>::iterator j; for(j=d[n].begin();j!=d[n].end();++j)ans=min(ans,j->second); if(ans!=inf)printf("%d\n",ans); else printf("-1\n"); return 0; }
a.cc: In function 'int main()': a.cc:50:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 50 | for(i=0;i<e[x][c].size;++i) | ()
s173786988
p04003
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <unordered_map> #include <deque> #define inf 0x3F3F3F3F using namespace std; struct Node { int x,c; }; deque<Node>q; unordered_map<int,vector<int> >e[100005]; unordered_map<int,int>d[100005]; int main(void) { int i,x,y,c,cost,n,m,ans=inf; scanf("%d%d",&n,&m); for(i=1;i<=m;++i) { scanf("%d%d%d",&x,&y,&c); e[x][c].push_back(y); e[y][c].push_back(x); g[x].push_back(c); g[y].push_back(c); } d[0][0]=0;q.push_back((Node){1,0}); while(!q.empty()) { x=q.front().x;c=q.front().c;cost=d[x][c];q.pop_front(); if(d[x].find(0)==d[x].end()||d[x][0]>cost) { d[x][0]=cost;q.push_front((Node){x,0}); } if(c==0) { for(i=1;i<g[x].size();++i) { y=g[x][i]; if(d[x].find(y)==d[x].end()||d[x][y]>cost+1) { d[x][y]=cost+1;q.push_back((Node){x,y}); } } continue; } for(i=0;i<e[x][c].size;++i) { y=e[x][c][i]; if(d[y].find(c)==d[y].end()||d[y][c]>cost) { d[y][c]=cost;q.push_front((Node){y,c}); } } } unordered_map<int,int>::iterator j; for(j=d[n].begin();j!=d[n].end();++j)ans=min(ans,j->second); if(ans!=inf)printf("%d\n",ans); else printf("-1\n"); return 0; }
a.cc: In function 'int main()': a.cc:26:17: error: 'g' was not declared in this scope 26 | g[x].push_back(c); | ^ a.cc:39:35: error: 'g' was not declared in this scope 39 | for(i=1;i<g[x].size();++i) | ^ a.cc:49:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 49 | for(i=0;i<e[x][c].size;++i) | ()
s905716066
p04003
C++
#include<bits/stdc++.h> using namespace std; #define MAX 1000005 #define pb push_back #define mp make_pair typedef pair<int,int> pi; int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; vector<pi> jie[MAX]; vector<int> shua[MAX]; bool vis[MAX]; inline int find(int x) { if(x==par[x]) return x; return par[x]=find(par[x]); } inline void inint(int x) { par[x]=x; rank[x]=0; } inline void unite(int x, int y) { x=find(x), y=find(y); if(x==y) return; if(rank[x]<rank[y]) { par[x]=y; return; } par[y]=x; if(rank[x]==rank[y]) rank[x]++; return; } int main() { memset(step, -1, sizeof(step)); scanf("%d %d", &N, &M); while(M--) { scanf("%d %d %d", &a, &b, &c); mx=max(mx, c); a--, b--, c--; jie[c].pb(mp(a, b)); } int yy=N; for(int i=0; i<mx; i++) { for(int j=0; j<jie[i].size(); j++) { pi hh=jie[i][j]; inint(hh.first); id[hh.first]=-1; vis[hh.first]=false; inint(hh.second); id[hh.second]=-1; vis[hh.second]=false; } for(int j=0; j<jie[i].size(); j++) { pi hh=jie[i][j]; unite(hh.first, hh.second); } for(int j=0; j<jie[i].size(); j++) { pi hh=jie[i][j]; if(!vis[hh.first]) { vis[hh.first]=true; int r=find(hh.first); if(id[r]==-1) id[r]=yy++; shua[id[r]].pb(hh.first); shua[hh.first].pb(id[r]); } swap(hh.first, hh.second); if(!vis[hh.first]) { vis[hh.first]=true; int r=find(hh.first); if(id[r]==-1) id[r]=yy++; shua[id[r]].pb(hh.first); shua[hh.first].pb(id[r]); } } } queue<int> q; q.push(0); step[0]=0; while(!q.empty()) { int t=q.front(); q.pop(); if(step[N-1]>-1) break; for(int i=0; i<shua[t].size(); i++) { if(step[shua[t][i]]==-1) { step[shua[t][i]]=step[t]+1; q.push(shua[t][i]); } } } if(step[N-1]==-1) printf("%d", -1); else printf("%d", step[N-1]/2); return 0; }
a.cc: In function 'void inint(int)': a.cc:22:9: error: reference to 'rank' is ambiguous 22 | rank[x]=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:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:29:12: error: reference to 'rank' is ambiguous 29 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:29:20: error: reference to 'rank' is ambiguous 29 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:35:12: error: reference to 'rank' is ambiguous 35 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:35:21: error: reference to 'rank' is ambiguous 35 | 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:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~ a.cc:36:17: error: reference to 'rank' is ambiguous 36 | rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:8:30: note: 'int rank [1000005]' 8 | int N, M, a, b, c, par[MAX], rank[MAX], step[MAX], mx=-1, id[MAX]; | ^~~~