#include<bits/stdc++.h>
#define ll long long
#define vt vector
#define pb push_back
#define pii pair<int, int>
#define sz(v) (int)v.size()
#define fi first
#define se second
using namespace std;
const ll base = 107, mod = 1e9 + 7, mxv = 1e4 + 5, inf = 1e9;
const int mxn = 5e3 + 5, N = 3e6 + 5;
int n, m;
int dis[mxn + 1];
bool vis[mxn + 1];
struct th{
int u, v, w;
};
vt<th>edge;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
int l, r, k, v; cin >> l >> r >> k >> v;
l++; r++;
if(v == 1){
//pref[r] - k >= pref[l - 1]
k = (r - l + 1) - k + 1;
edge.pb({r, l - 1, -k});
//cout << r << " " << l - 1 << " " << -k << "\n";
}else{
k = (r - l + 1) - k;
edge.pb({l - 1, r, k});
// cout << l - 1 << " " << r << " " << k << "\n";
}
}
for(int i = 1; i <= n; i++){
edge.pb({i, i - 1, 0});
}
for(int i = 1; i <= n; i++)dis[i] = inf;
dis[0] = 0;
bool no = 0;
for(int i = 1; i <= n + 10; i++){
for(auto [u, v, w]: edge){
if(dis[v] > dis[u] + w){
dis[v] = dis[u] + w;
}
}
}
for(int i = 1; i <= n; i++){
if(dis[i] == inf)dis[i] = dis[i - 1];
}
if(no)cout << -1 << "\n";
else{
for(int i = 1; i <= n; i++)cout << dis[i] - dis[i - 1] << " ";
}
}
Compilation message
restore.cpp: In function 'int main()':
restore.cpp:43:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
43 | for(auto [u, v, w]: edge){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Integer 2 violates the range [-1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
856 KB |
Integer 336 violates the range [-1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
856 KB |
Integer 336 violates the range [-1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Integer 2 violates the range [-1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |