Submission #296646

# Submission time Handle Problem Language Result Execution time Memory
296646 2020-09-10T17:56:19 Z Pajaraja Restore Array (RMI19_restore) C++17
100 / 100
402 ms 892 KB
#include <bits/stdc++.h>
#define MAXN 5007
using namespace std;
int dist[MAXN],dn[MAXN],ep[10*MAXN],ek[10*MAXN],ev[10*MAXN],br;
int n,m;
void zvonocovek() {for(int i=0;i<br;i++) dist[ek[i]]=min(dist[ek[i]],dist[ep[i]]+ev[i]);}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++) {ek[br]=i; ep[br]=i+1; ev[br]=0; br++;}
	for(int i=0;i<n;i++) {ek[br]=i+1; ep[br]=i; ev[br]=1; br++;}
	for(int i=0;i<m;i++)
	{
		int a,b,k,v; cin>>a>>b>>k>>v; a++; b++;
		if(v==0) {ek[br]=b; ep[br]=a-1; ev[br]=b+1-a-k; br++;} 
		else {ek[br]=a-1; ep[br]=b; ev[br]=k+a-2-b; br++;}
	}
	for(int i=1;i<=n;i++) dist[i]=1000000000;
	for(int i=0;i<n;i++) zvonocovek();
	for(int i=0;i<=n;i++) dn[i]=dist[i];
	zvonocovek();
	for(int i=0;i<=n;i++) if(dn[i]!=dist[i]) {printf("-1"); return 0;}
	for(int i=0;i<n;i++) printf("%d ",dist[i+1]-dist[i]); 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 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 376 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 380 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 760 KB Output is correct
2 Correct 367 ms 760 KB Output is correct
3 Correct 367 ms 760 KB Output is correct
4 Correct 369 ms 740 KB Output is correct
5 Correct 329 ms 760 KB Output is correct
6 Correct 351 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 760 KB Output is correct
2 Correct 367 ms 760 KB Output is correct
3 Correct 367 ms 760 KB Output is correct
4 Correct 369 ms 740 KB Output is correct
5 Correct 329 ms 760 KB Output is correct
6 Correct 351 ms 760 KB Output is correct
7 Correct 386 ms 888 KB Output is correct
8 Correct 384 ms 784 KB Output is correct
9 Correct 373 ms 888 KB Output is correct
10 Correct 364 ms 768 KB Output is correct
11 Correct 361 ms 768 KB Output is correct
12 Correct 371 ms 764 KB Output is correct
13 Correct 375 ms 756 KB Output is correct
14 Correct 389 ms 776 KB Output is correct
15 Correct 389 ms 888 KB Output is correct
16 Correct 386 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 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 376 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 380 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 362 ms 760 KB Output is correct
12 Correct 367 ms 760 KB Output is correct
13 Correct 367 ms 760 KB Output is correct
14 Correct 369 ms 740 KB Output is correct
15 Correct 329 ms 760 KB Output is correct
16 Correct 351 ms 760 KB Output is correct
17 Correct 386 ms 888 KB Output is correct
18 Correct 384 ms 784 KB Output is correct
19 Correct 373 ms 888 KB Output is correct
20 Correct 364 ms 768 KB Output is correct
21 Correct 361 ms 768 KB Output is correct
22 Correct 371 ms 764 KB Output is correct
23 Correct 375 ms 756 KB Output is correct
24 Correct 389 ms 776 KB Output is correct
25 Correct 389 ms 888 KB Output is correct
26 Correct 386 ms 776 KB Output is correct
27 Correct 371 ms 760 KB Output is correct
28 Correct 383 ms 768 KB Output is correct
29 Correct 377 ms 768 KB Output is correct
30 Correct 378 ms 776 KB Output is correct
31 Correct 362 ms 736 KB Output is correct
32 Correct 369 ms 892 KB Output is correct
33 Correct 402 ms 768 KB Output is correct
34 Correct 378 ms 760 KB Output is correct
35 Correct 376 ms 888 KB Output is correct
36 Correct 372 ms 768 KB Output is correct