Submission #55580896


Source Code Expand

//~ mail ID : neernpatel@gmail.com
//~ Author : DrexDelta
//~ codechef : drexdelta , hackerRank : drexdelta , codeforces : drexdelta1
//~ Contact Info : neernpatel@gmail.com

#include <iostream>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>


using namespace std;

#define F first
#define S second
#define MP make_pair
#define PB push_back
#define UB upper_bound
#define LB lower_bound
#define ER erase
#define EN end()
#define B begin()
#define I insert
#define OPTIMIZE ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int ll
#define endl "\n"
#define CO cout <<
#define CI cin >>
#define NL cout << endl;
#define DBG {int debug ; cin >> debug;}
#define AND &&
#define OR ||
#define XOR ^
#define OFLUSH fflush(stdout);
#define IFLUSH fflush(stdin);
#define LEN(x) ((int)x.length())

#define rep(i,x) for(int i = 0 ; i < x ; i++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i++)

#define repl(var,start_val,limit_val) for(int var = start_val ; var <= limit_val ; var++)
#define perl(var,start_val,limit_val) for(int var = start_val ; var >= limit_val ; var--)

#define y1 qwert
#define y2 trewq
#define x1 asdfg
#define x2 gfdsa

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef long double ld;

const ll maxn = 5e5+6 ;
const ll MOD = 1e9 + 7 ;


int n , m, k, H, a[maxn], ans[maxn];

string s;
vii g[maxn];

set<string> ms;

void getInput() {
    cin >> n >> m;
    // cin >> s;
    repl(i,1,n) cin >> a[i];
	// sort(a + 1 , a + n + 1);
    int x , y, w;
    repl(i,1,m) {
        cin >> x >> y >> w;
        g[x].PB(MP(y,w));
        g[y].PB(MP(x,w));
    }
}

void solve() {

	repl(i,1,n) {
		ans[i] = 1LL * 1e9 * 1e9;
	}
	set<ii> q;

	q.insert(MP(0,1));
	ans[1] = 0;
	while(q.size()) {
		ii p = *q.begin();
		q.erase(q.begin());
		int v = p.S;
		ans[v] += a[v];

		for(auto u : g[v]) {
			if(ans[u.F] > ans[v] + u.S) {
				q.erase(MP(ans[u.F],u.F));
				ans[u.F] = ans[v] + u.S;
				q.insert(MP(ans[u.F],u.F));
			}
		}
	}
	repl(i,2,n) {
		cout << ans[i] << " ";
	}
	NL 
}

signed main() {
    // factinit();
    // generatePrimes();

    OPTIMIZE
    //freopen("in.txt" , "r" , stdin) ;
    //freopen("out.txt" , "w" , stdout) ;

    int t=1;
    // cin >> t;
    while(t--)
        getInput() , solve();

	return 0;

}

Submission Info

Submission Time
Task D - Shortest Path 3
User drexdelta
Language C++ 20 (gcc 12.2)
Score 0
Code Size 3163 Byte
Status WA
Exec Time 140 ms
Memory 32960 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:155:5: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
  155 |     while(t--)
      |     ^~~~~
Main.cpp:158:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
  158 |         return 0;
      |         ^~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
AC × 3
AC × 23
WA × 18
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random-small_01.txt, 01_random-small_02.txt, 01_random-small_03.txt, 01_random-small_04.txt, 01_random-small_05.txt, 01_random-small_06.txt, 01_random-small_07.txt, 01_random-small_08.txt, 01_random-small_09.txt, 01_random-small_10.txt, 01_random-small_11.txt, 01_random-small_12.txt, 01_random-small_13.txt, 01_random-small_14.txt, 01_random-small_15.txt, 02_random-large_01.txt, 02_random-large_02.txt, 02_random-large_03.txt, 02_random-large_04.txt, 02_random-large_05.txt, 02_random-large_06.txt, 02_random-large_07.txt, 02_random-large_08.txt, 02_random-large_09.txt, 02_random-large_10.txt, 02_random-large_11.txt, 02_random-large_12.txt, 02_random-large_13.txt, 02_random-large_14.txt, 02_random-large_15.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 3 ms 3500 KiB
00_sample_02.txt AC 3 ms 3436 KiB
00_sample_03.txt AC 3 ms 3436 KiB
01_random-small_01.txt AC 3 ms 3532 KiB
01_random-small_02.txt AC 3 ms 3592 KiB
01_random-small_03.txt AC 3 ms 3548 KiB
01_random-small_04.txt AC 3 ms 3656 KiB
01_random-small_05.txt WA 31 ms 12956 KiB
01_random-small_06.txt WA 9 ms 5476 KiB
01_random-small_07.txt WA 6 ms 4412 KiB
01_random-small_08.txt WA 24 ms 10800 KiB
01_random-small_09.txt WA 3 ms 3500 KiB
01_random-small_10.txt WA 13 ms 6088 KiB
01_random-small_11.txt WA 5 ms 4028 KiB
01_random-small_12.txt WA 10 ms 5464 KiB
01_random-small_13.txt WA 33 ms 12112 KiB
01_random-small_14.txt WA 3 ms 3592 KiB
01_random-small_15.txt WA 11 ms 5864 KiB
02_random-large_01.txt AC 69 ms 14120 KiB
02_random-large_02.txt AC 134 ms 22736 KiB
02_random-large_03.txt AC 7 ms 4512 KiB
02_random-large_04.txt AC 137 ms 22992 KiB
02_random-large_05.txt WA 94 ms 16992 KiB
02_random-large_06.txt AC 135 ms 22696 KiB
02_random-large_07.txt WA 109 ms 19132 KiB
02_random-large_08.txt AC 136 ms 22952 KiB
02_random-large_09.txt WA 69 ms 13800 KiB
02_random-large_10.txt AC 133 ms 22764 KiB
02_random-large_11.txt WA 130 ms 22080 KiB
02_random-large_12.txt AC 134 ms 22720 KiB
02_random-large_13.txt WA 120 ms 20816 KiB
02_random-large_14.txt AC 140 ms 22908 KiB
02_random-large_15.txt WA 65 ms 14364 KiB
03_handmade_01.txt AC 106 ms 21756 KiB
03_handmade_02.txt AC 102 ms 21836 KiB
03_handmade_03.txt AC 135 ms 32960 KiB
03_handmade_04.txt WA 35 ms 13952 KiB
03_handmade_05.txt AC 94 ms 21796 KiB
03_handmade_06.txt AC 88 ms 21124 KiB
03_handmade_07.txt AC 3 ms 3644 KiB
03_handmade_08.txt AC 3 ms 3496 KiB