fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define pii pair<int,int>
  5. #define pll pair<ll,ll>
  6. #define plll pair<ll,pll>
  7. #define tull tuple<ll,ll,ll>
  8. #define pb push_back
  9. #define f first
  10. #define endl '\n'
  11. #define se second
  12. #define piii pair<int,pii>
  13. #define id1 id<<1
  14. #define bit(x,i) (((x) >> (i)) & 1)
  15. #define id2 (id<<1)+1
  16. #define MASK(i) (1<<i)
  17. #define set_on(x,i) ((x) | MASK(i))
  18. #define set_off(x,i) ((x) & ~MASK(i))
  19. #define TIME "\nTime elapsed : "<<(double)clock()/1000<<" ms"
  20. #define all(x) x.begin(),x.end()
  21. #define id(i,j) (i - 1) * m + j
  22. #define TASK "test"
  23. #define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  24. using namespace std;
  25. const ll mod = 1e9 + 7; //998244353;
  26. const ll base = 311;
  27. const ll INF = 1e18;
  28. const ll maxn = 1e6 + 5;
  29. const ll maxs = 1e5;
  30. const ld pi = 3.14159265358979323846;
  31. const ll dx[] = {-1,0,0,1};
  32. const ll dy[] = {0,-1,1,0};
  33. const int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
  34. const int dy8[] = {0, 1, 0, -1, 1, -1, 1, -1};
  35.  
  36. int n,m;
  37. ll d[maxn][2];
  38. vector<pii> adj[maxn];
  39.  
  40. void dijkstra(int s)
  41. {
  42. for(int i = 0; i <= n; ++i){
  43. for(int j = 0; j <= 2; ++j){
  44. d[i][j] = INF;
  45. }
  46. }
  47. priority_queue<plll,vector<plll>,greater<plll>> pq;
  48. while(!pq.empty()) pq.pop();
  49.  
  50. d[s][0] = 0;
  51. pq.push({0,{0,s}});
  52.  
  53. while(!pq.empty()){
  54. ll u = pq.top().se.se;
  55. ll w = pq.top().f;
  56. ll k = pq.top().se.f;
  57. pq.pop();
  58.  
  59. if(w != d[u][k]){
  60. continue;
  61. }
  62.  
  63. for(auto [v,kc] : adj[u]){
  64. if(k == 0){
  65. if(d[v][1] > d[u][k] + kc/2){
  66. d[v][1] = d[u][k] + kc/2;
  67. pq.push({d[v][1],{1,v}});
  68. }
  69. }
  70.  
  71. if(d[v][k] > d[u][k] + kc){
  72. d[v][k] = d[u][k] + kc;
  73. pq.push({d[v][k],{k,v}});
  74. }
  75. }
  76. }
  77. }
  78.  
  79. int main()
  80. {
  81. fast
  82.  
  83. cin >> n >> m;
  84.  
  85. for(int i = 1; i <= m; ++i){
  86. int u,v,w;
  87. cin >> u >> v >> w;
  88. adj[u].pb({v,w});
  89. }
  90.  
  91. dijkstra(1);
  92.  
  93. cout << d[n][1];
  94.  
  95. return 0;
  96. }
  97.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
Main.java:2: error: illegal character: '#'
#define ll long long
^
Main.java:3: error: illegal character: '#'
#define ld long double
^
Main.java:4: error: illegal character: '#'
#define pii pair<int,int>
^
Main.java:5: error: illegal character: '#'
#define pll pair<ll,ll>
^
Main.java:6: error: illegal character: '#'
#define plll pair<ll,pll>
^
Main.java:7: error: illegal character: '#'
#define tull tuple<ll,ll,ll>
^
Main.java:8: error: illegal character: '#'
#define pb push_back
^
Main.java:9: error: illegal character: '#'
#define f first
^
Main.java:10: error: illegal character: '#'
#define endl '\n'
^
Main.java:11: error: illegal character: '#'
#define se second
^
Main.java:12: error: illegal character: '#'
#define piii pair<int,pii>
^
Main.java:13: error: illegal character: '#'
#define id1 id<<1
^
Main.java:14: error: illegal character: '#'
#define bit(x,i) (((x) >> (i)) & 1)
^
Main.java:15: error: illegal character: '#'
#define id2 (id<<1)+1
^
Main.java:16: error: illegal character: '#'
#define MASK(i) (1<<i)
^
Main.java:17: error: illegal character: '#'
#define set_on(x,i) ((x) | MASK(i))
^
Main.java:18: error: illegal character: '#'
#define set_off(x,i) ((x) & ~MASK(i))
^
Main.java:19: error: illegal character: '#'
#define TIME "\nTime elapsed : "<<(double)clock()/1000<<" ms"
^
Main.java:20: error: illegal character: '#'
#define all(x) x.begin(),x.end()
^
Main.java:21: error: illegal character: '#'
#define id(i,j) (i - 1) * m + j
^
Main.java:22: error: illegal character: '#'
#define TASK "test"
^
Main.java:23: error: illegal character: '#'
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
^
Main.java:23: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
                                           ^
Main.java:23: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
                                                      ^
Main.java:24: error: class, interface, or enum expected
using namespace std;
^
Main.java:25: error: class, interface, or enum expected
const ll mod = 1e9 + 7; //998244353;
^
Main.java:26: error: class, interface, or enum expected
const ll base = 311;
^
Main.java:27: error: class, interface, or enum expected
const ll INF = 1e18;
^
Main.java:28: error: class, interface, or enum expected
const ll maxn = 1e6 + 5;
^
Main.java:29: error: class, interface, or enum expected
const ll maxs = 1e5;
^
Main.java:30: error: class, interface, or enum expected
const ld pi = 3.14159265358979323846;
^
Main.java:31: error: class, interface, or enum expected
const ll dx[] = {-1,0,0,1};
^
Main.java:32: error: class, interface, or enum expected
const ll dy[] = {0,-1,1,0};
^
Main.java:33: error: class, interface, or enum expected
const int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
^
Main.java:34: error: class, interface, or enum expected
const int dy8[] = {0, 1, 0, -1, 1, -1, 1, -1};
^
Main.java:36: error: class, interface, or enum expected
int n,m;
^
Main.java:37: error: class, interface, or enum expected
ll d[maxn][2];
^
Main.java:38: error: class, interface, or enum expected
vector<pii> adj[maxn];
^
Main.java:40: error: class, interface, or enum expected
void dijkstra(int s)
^
Main.java:42: error: class, interface, or enum expected
    for(int i = 0; i <= n; ++i){
                   ^
Main.java:42: error: class, interface, or enum expected
    for(int i = 0; i <= n; ++i){
                           ^
Main.java:43: error: class, interface, or enum expected
        for(int j = 0; j <= 2; ++j){
                       ^
Main.java:43: error: class, interface, or enum expected
        for(int j = 0; j <= 2; ++j){
                               ^
Main.java:45: error: class, interface, or enum expected
        }
        ^
Main.java:48: error: class, interface, or enum expected
    while(!pq.empty()) pq.pop();
    ^
Main.java:50: error: class, interface, or enum expected
    d[s][0] = 0;
    ^
Main.java:51: error: class, interface, or enum expected
    pq.push({0,{0,s}});
    ^
Main.java:53: error: class, interface, or enum expected
    while(!pq.empty()){
    ^
Main.java:55: error: class, interface, or enum expected
        ll w = pq.top().f;
        ^
Main.java:56: error: class, interface, or enum expected
        ll k = pq.top().se.f;
        ^
Main.java:57: error: class, interface, or enum expected
        pq.pop();
        ^
Main.java:59: error: class, interface, or enum expected
        if(w != d[u][k]){
        ^
Main.java:61: error: class, interface, or enum expected
        }
        ^
Main.java:67: error: class, interface, or enum expected
                    pq.push({d[v][1],{1,v}});
                    ^
Main.java:68: error: class, interface, or enum expected
                }
                ^
Main.java:73: error: class, interface, or enum expected
                pq.push({d[v][k],{k,v}});
                ^
Main.java:74: error: class, interface, or enum expected
            }
            ^
Main.java:85: error: class, interface, or enum expected
    for(int i = 1; i <= m; ++i){
    ^
Main.java:85: error: class, interface, or enum expected
    for(int i = 1; i <= m; ++i){
                   ^
Main.java:85: error: class, interface, or enum expected
    for(int i = 1; i <= m; ++i){
                           ^
Main.java:87: error: class, interface, or enum expected
        cin >> u >> v >> w;
        ^
Main.java:88: error: class, interface, or enum expected
        adj[u].pb({v,w});
        ^
Main.java:89: error: class, interface, or enum expected
    }
    ^
Main.java:93: error: class, interface, or enum expected
    cout << d[n][1];
    ^
Main.java:95: error: class, interface, or enum expected
    return 0;
    ^
Main.java:96: error: class, interface, or enum expected
}
^
68 errors
stdout
Standard output is empty