Submission #961568

# Submission time Handle Problem Language Result Execution time Memory
961568 2024-04-12T08:15:34 Z blacktulip Restore Array (RMI19_restore) C++17
100 / 100
330 ms 1624 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define pb push_back
#define fi first
#define se second
 
const int li=500005;
int x[li],y[li],w[li],c[li],n,m;
vector<pair<int,pair<int,int>>> v;
 
void bellman_ford(){
	for(int j=1;j<=n+1;j++){
		for(auto go:v){
			if(c[go.fi]+go.se.se<c[go.se.fi]){
				if(j==n+1){cout<<"-1\n";exit(0);}
				c[go.se.fi]=c[go.fi]+go.se.se;
			}
		}
	}
}
 
int32_t main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		v.pb({i,{i+1,1}});
		v.pb({i+1,{i,0}});
	}
	for(int i=1;i<=m;i++){
		int l,r,k,value;
		cin>>l>>r>>k>>value;
		if(value==0){
			v.pb({l,{r+1,r-l+1-k}});
		}
		else v.pb({r+1,{l,-(r-l+1-k+1)}});
	}
	c[0]=0;
	for(int i=1;i<=n;i++)c[i]=100000000000000;
	bellman_ford();
	for(int i=1;i<=n;i++){
		cout<<c[i]-c[i-1]<<" ";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 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 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 1112 KB Output is correct
2 Correct 97 ms 1112 KB Output is correct
3 Correct 99 ms 1108 KB Output is correct
4 Correct 102 ms 1112 KB Output is correct
5 Correct 254 ms 1364 KB Output is correct
6 Correct 244 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 1112 KB Output is correct
2 Correct 97 ms 1112 KB Output is correct
3 Correct 99 ms 1108 KB Output is correct
4 Correct 102 ms 1112 KB Output is correct
5 Correct 254 ms 1364 KB Output is correct
6 Correct 244 ms 1364 KB Output is correct
7 Correct 106 ms 1476 KB Output is correct
8 Correct 99 ms 1364 KB Output is correct
9 Correct 111 ms 1368 KB Output is correct
10 Correct 109 ms 1368 KB Output is correct
11 Correct 329 ms 1368 KB Output is correct
12 Correct 330 ms 1364 KB Output is correct
13 Correct 101 ms 1364 KB Output is correct
14 Correct 106 ms 1624 KB Output is correct
15 Correct 107 ms 1364 KB Output is correct
16 Correct 109 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 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 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 100 ms 1112 KB Output is correct
12 Correct 97 ms 1112 KB Output is correct
13 Correct 99 ms 1108 KB Output is correct
14 Correct 102 ms 1112 KB Output is correct
15 Correct 254 ms 1364 KB Output is correct
16 Correct 244 ms 1364 KB Output is correct
17 Correct 106 ms 1476 KB Output is correct
18 Correct 99 ms 1364 KB Output is correct
19 Correct 111 ms 1368 KB Output is correct
20 Correct 109 ms 1368 KB Output is correct
21 Correct 329 ms 1368 KB Output is correct
22 Correct 330 ms 1364 KB Output is correct
23 Correct 101 ms 1364 KB Output is correct
24 Correct 106 ms 1624 KB Output is correct
25 Correct 107 ms 1364 KB Output is correct
26 Correct 109 ms 1356 KB Output is correct
27 Correct 100 ms 1440 KB Output is correct
28 Correct 107 ms 1332 KB Output is correct
29 Correct 98 ms 1328 KB Output is correct
30 Correct 102 ms 1368 KB Output is correct
31 Correct 96 ms 1368 KB Output is correct
32 Correct 118 ms 1364 KB Output is correct
33 Correct 270 ms 1376 KB Output is correct
34 Correct 317 ms 1368 KB Output is correct
35 Correct 117 ms 1368 KB Output is correct
36 Correct 99 ms 1368 KB Output is correct