Submission #961559

# Submission time Handle Problem Language Result Execution time Memory
961559 2024-04-12T08:06:00 Z blacktulip Restore Array (RMI19_restore) C++17
0 / 100
105 ms 1368 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]=1000000000000000000;
	bellman_ford();
	for(int i=1;i<=n;i++){
		cout<<c[i]-c[i-1]<<" ";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 101 ms 1368 KB Output is correct
2 Correct 100 ms 1368 KB Output is correct
3 Correct 105 ms 1368 KB Output is correct
4 Incorrect 98 ms 1364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 101 ms 1368 KB Output is correct
2 Correct 100 ms 1368 KB Output is correct
3 Correct 105 ms 1368 KB Output is correct
4 Incorrect 98 ms 1364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -