fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5.  
  6. #define sc scanf
  7. #define pf printf
  8. #define sci(n) scanf("%d",&n)
  9. #define scl(n) scanf("%lld",&n)
  10. #define scii(n,m) scanf("%d %d",&n,&m)
  11. #define pfi(n) printf("%d",n)
  12. #define pfl(n) printf("%lld",n)
  13. #define line printf("\n")
  14. #define spc printf(" ")
  15. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  16. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  17. #define clr(a,x) memset(a,x,sizeof(a))
  18. #define pb push_back
  19. #define mpp make_pair
  20. #define ff first
  21. #define ss second
  22. #define all(v) v.begin(),v.end()
  23. #define rall(v) v.rbegin(),v.rend()
  24. #define read() freopen("input.txt", "r", stdin)
  25. #define write() freopen("output.txt", "w", stdout)
  26. #define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL);
  27. /// Constants
  28. #define eps 1e-9
  29. #define PI acos(-1.0) // 3.1415926535897932
  30. #define MAX 100000009
  31.  
  32.  
  33. int main()
  34. {
  35. //read();
  36. //write();
  37. int n,m;
  38. cin>>n>>m;
  39. map< char, set< pair<int, char> > > mp;
  40. map<char, int> val;
  41. char s, d;
  42. cin>>s>>d;
  43. for(int i=1;i<=m;i++){
  44. char u,v;
  45. int x;
  46. cin>>u>>v>>x;
  47. mp[u].insert(mpp(x,v));
  48. mp[v].insert(mpp(x,u));
  49. val[u]=MAX;
  50. val[v]=MAX;
  51. }
  52. set< pair<int, char> > qu;
  53. qu.insert(mpp(0,s));
  54. while(qu.size()){
  55. set< pair<int, char> >::iterator it,itt;
  56. it = qu.begin();
  57. int vl = it.ff;
  58. char u = it.ss;
  59. qu.erase(it);
  60. itt = mp[u].begin();
  61. for(;itt!=mp[u].end();itt++){
  62. if(vl+itt.ff<=val[itt.ss]){
  63. val[itt.ss]=vl+itt.ff;
  64. qu.insert(mpp(val[itt.ss],itt.ss));
  65. }
  66. }
  67. }
  68. cout<<val[v]<<endl;
  69. return 0;
  70. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 5
A E
A B 5
A C 6
A D 3
A E 7
D E 2
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘first’
 #define ff                 first
                            ^~~~~
prog.cpp:57:21: note: in expansion of macro ‘ff’
         int vl = it.ff;
                     ^~
prog.cpp:21:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘second’
 #define ss                 second
                            ^~~~~~
prog.cpp:58:21: note: in expansion of macro ‘ss’
         char u = it.ss;
                     ^~
prog.cpp:20:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘first’
 #define ff                 first
                            ^~~~~
prog.cpp:62:23: note: in expansion of macro ‘ff’
             if(vl+itt.ff<=val[itt.ss]){
                       ^~
prog.cpp:21:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘second’
 #define ss                 second
                            ^~~~~~
prog.cpp:62:35: note: in expansion of macro ‘ss’
             if(vl+itt.ff<=val[itt.ss]){
                                   ^~
prog.cpp:21:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘second’
 #define ss                 second
                            ^~~~~~
prog.cpp:63:25: note: in expansion of macro ‘ss’
                 val[itt.ss]=vl+itt.ff;
                         ^~
prog.cpp:20:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘first’
 #define ff                 first
                            ^~~~~
prog.cpp:63:36: note: in expansion of macro ‘ff’
                 val[itt.ss]=vl+itt.ff;
                                    ^~
prog.cpp:21:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘second’
 #define ss                 second
                            ^~~~~~
prog.cpp:64:39: note: in expansion of macro ‘ss’
                 qu.insert(mpp(val[itt.ss],itt.ss));
                                       ^~
prog.cpp:21:28: error: ‘std::set<std::pair<int, char> >::iterator’ {aka ‘struct std::_Rb_tree_const_iterator<std::pair<int, char> >’} has no member named ‘second’
 #define ss                 second
                            ^~~~~~
prog.cpp:64:47: note: in expansion of macro ‘ss’
                 qu.insert(mpp(val[itt.ss],itt.ss));
                                               ^~
prog.cpp:68:15: error: ‘v’ was not declared in this scope
     cout<<val[v]<<endl;
               ^
stdout
Standard output is empty