Submission #1049325

# Submission time Handle Problem Language Result Execution time Memory
1049325 2024-08-08T16:30:47 Z PlayVoltz Restore Array (RMI19_restore) C++17
100 / 100
130 ms 1620 KB
#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
#include <random>
#include <fstream>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

struct trio{
	int a, b, c;
};

int32_t main(){
	int n, m, a, b, c, d;
	cin>>n>>m;
	vector<int> psum(n+1, LLONG_MAX/2);
  	psum[0]=0;
	vector<trio> vect;
	while (m--){
		cin>>a>>b>>c>>d;
		++a, ++b;
		if (d)vect.pb({a-1, b, c-1});
		else vect.pb({b, a-1, -c});
	}
	for (int i=1; i<=n; ++i)vect.pb({i-1, i, 1}), vect.pb({i, i-1, 0});
	for (int i=0; i<n; ++i)for (auto [b, a, c]:vect)psum[a]=min(psum[a], psum[b]+c);
	for (auto [b, a, c]:vect)if (psum[b]+c<psum[a]){cout<<-1;return 0;}
	for (int i=1; i<=n; ++i)cout<<!(psum[i]-psum[i-1])<<" ";
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 1364 KB Output is correct
2 Correct 130 ms 1368 KB Output is correct
3 Correct 117 ms 1368 KB Output is correct
4 Correct 122 ms 1428 KB Output is correct
5 Correct 118 ms 1364 KB Output is correct
6 Correct 116 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 1364 KB Output is correct
2 Correct 130 ms 1368 KB Output is correct
3 Correct 117 ms 1368 KB Output is correct
4 Correct 122 ms 1428 KB Output is correct
5 Correct 118 ms 1364 KB Output is correct
6 Correct 116 ms 1364 KB Output is correct
7 Correct 119 ms 1368 KB Output is correct
8 Correct 122 ms 1364 KB Output is correct
9 Correct 121 ms 1368 KB Output is correct
10 Correct 119 ms 1368 KB Output is correct
11 Correct 115 ms 1368 KB Output is correct
12 Correct 121 ms 1368 KB Output is correct
13 Correct 116 ms 1364 KB Output is correct
14 Correct 119 ms 1364 KB Output is correct
15 Correct 120 ms 1364 KB Output is correct
16 Correct 121 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 125 ms 1364 KB Output is correct
12 Correct 130 ms 1368 KB Output is correct
13 Correct 117 ms 1368 KB Output is correct
14 Correct 122 ms 1428 KB Output is correct
15 Correct 118 ms 1364 KB Output is correct
16 Correct 116 ms 1364 KB Output is correct
17 Correct 119 ms 1368 KB Output is correct
18 Correct 122 ms 1364 KB Output is correct
19 Correct 121 ms 1368 KB Output is correct
20 Correct 119 ms 1368 KB Output is correct
21 Correct 115 ms 1368 KB Output is correct
22 Correct 121 ms 1368 KB Output is correct
23 Correct 116 ms 1364 KB Output is correct
24 Correct 119 ms 1364 KB Output is correct
25 Correct 120 ms 1364 KB Output is correct
26 Correct 121 ms 1368 KB Output is correct
27 Correct 117 ms 1620 KB Output is correct
28 Correct 120 ms 1368 KB Output is correct
29 Correct 117 ms 1364 KB Output is correct
30 Correct 120 ms 1364 KB Output is correct
31 Correct 115 ms 1364 KB Output is correct
32 Correct 117 ms 1368 KB Output is correct
33 Correct 120 ms 1364 KB Output is correct
34 Correct 117 ms 1368 KB Output is correct
35 Correct 122 ms 1368 KB Output is correct
36 Correct 120 ms 1364 KB Output is correct