# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
313834 | 2020-10-17T07:02:35 Z | MKopchev | Restore Array (RMI19_restore) | C++14 | 387 ms | 1012 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=5e3+42; struct edge { int u,v,cost; }; vector<edge> all; int n,q; int dist[nmax]; void bellman() { for(int i=1;i<=n;i++)dist[i]=1e9; for(int t=0;t<=n;t++) { for(auto w:all) if(dist[w.u]+w.cost<dist[w.v]) { dist[w.v]=dist[w.u]+w.cost; //cout<<"update "<<w.u<<" "<<w.v<<" "<<w.cost<<endl; //for(int j=0;j<=n;j++)cout<<dist[j]<<" ";cout<<endl; } //for(int j=0;j<=n;j++)cout<<dist[j]<<" ";cout<<endl; } for(auto w:all) if(dist[w.u]+w.cost<dist[w.v]) { printf("-1\n"); exit(0); } for(int i=1;i<=n;i++) printf("%i ",dist[i]-dist[i-1]); printf("\n"); } int main() { scanf("%i%i",&n,&q); for(int i=0;i<n;i++) { edge cur; cur.u=i; cur.v=i+1; cur.cost=1; all.push_back(cur); cur.u=i+1; cur.v=i; cur.cost=0; all.push_back(cur); } for(int i=1;i<=q;i++) { edge cur; int l,r,k,val; scanf("%i%i%i%i",&l,&r,&k,&val); l++; r++; if(val==0) { cur.u=l-1; cur.v=r; cur.cost=(r-l+1)-(k+1)+1; all.push_back(cur); } else { cur.u=r; cur.v=l-1; cur.cost=-((r-l+1)-(k-1)); all.push_back(cur); } } /* for(auto w:all) cout<<w.u<<" "<<w.v<<" "<<w.cost<<endl; */ bellman(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 960 KB | Output is correct |
2 | Correct | 128 ms | 960 KB | Output is correct |
3 | Correct | 129 ms | 960 KB | Output is correct |
4 | Correct | 128 ms | 960 KB | Output is correct |
5 | Correct | 347 ms | 960 KB | Output is correct |
6 | Correct | 344 ms | 960 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 960 KB | Output is correct |
2 | Correct | 128 ms | 960 KB | Output is correct |
3 | Correct | 129 ms | 960 KB | Output is correct |
4 | Correct | 128 ms | 960 KB | Output is correct |
5 | Correct | 347 ms | 960 KB | Output is correct |
6 | Correct | 344 ms | 960 KB | Output is correct |
7 | Correct | 139 ms | 1012 KB | Output is correct |
8 | Correct | 132 ms | 960 KB | Output is correct |
9 | Correct | 131 ms | 960 KB | Output is correct |
10 | Correct | 131 ms | 960 KB | Output is correct |
11 | Correct | 373 ms | 952 KB | Output is correct |
12 | Correct | 387 ms | 960 KB | Output is correct |
13 | Correct | 127 ms | 960 KB | Output is correct |
14 | Correct | 133 ms | 960 KB | Output is correct |
15 | Correct | 138 ms | 1012 KB | Output is correct |
16 | Correct | 149 ms | 960 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 139 ms | 960 KB | Output is correct |
12 | Correct | 128 ms | 960 KB | Output is correct |
13 | Correct | 129 ms | 960 KB | Output is correct |
14 | Correct | 128 ms | 960 KB | Output is correct |
15 | Correct | 347 ms | 960 KB | Output is correct |
16 | Correct | 344 ms | 960 KB | Output is correct |
17 | Correct | 139 ms | 1012 KB | Output is correct |
18 | Correct | 132 ms | 960 KB | Output is correct |
19 | Correct | 131 ms | 960 KB | Output is correct |
20 | Correct | 131 ms | 960 KB | Output is correct |
21 | Correct | 373 ms | 952 KB | Output is correct |
22 | Correct | 387 ms | 960 KB | Output is correct |
23 | Correct | 127 ms | 960 KB | Output is correct |
24 | Correct | 133 ms | 960 KB | Output is correct |
25 | Correct | 138 ms | 1012 KB | Output is correct |
26 | Correct | 149 ms | 960 KB | Output is correct |
27 | Correct | 127 ms | 1012 KB | Output is correct |
28 | Correct | 141 ms | 960 KB | Output is correct |
29 | Correct | 128 ms | 1012 KB | Output is correct |
30 | Correct | 136 ms | 960 KB | Output is correct |
31 | Correct | 131 ms | 960 KB | Output is correct |
32 | Correct | 128 ms | 960 KB | Output is correct |
33 | Correct | 364 ms | 960 KB | Output is correct |
34 | Correct | 369 ms | 960 KB | Output is correct |
35 | Correct | 131 ms | 1012 KB | Output is correct |
36 | Correct | 128 ms | 1008 KB | Output is correct |