Submission #157754
Source Code Expand
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define lli long long int
#define all( gg ) gg.begin(),gg.end()
#define foreach( gg,itit ) for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define FP( ii,aa,bb ) for( int ii=aa;ii<=bb;ii++ )
#define FM( ii,aa,bb ) for( int ii=aa;ii>=bb;ii-- )
using namespace std;
int n,X[20014],Y[20014],dp[3][2014][2];
int main(){
scanf("%d",&n);
FP( i,1,n )
scanf("%d %d",X+i,Y+i);
int ind,x,y,h=0;
FM( ind,n-1,0 ){
h ^= 1;
FP( k,-1000,1000 ){
FP( t,0,1 ){
if( t==0 ) x=k,y=Y[ind];
else x=X[ind],y=k;
dp[h][k+1000][t] = min( dp[h^1][y+1000][1]+abs(x-X[ind+1]),dp[h^1][x+1000][0]+abs(y-Y[ind+1]) );
}
}
}
cout << dp[h][1000][0] << endl;
}
Submission Info
Submission Time
2014-04-08 15:13:06+0900
Task
1 - Hermes
User
enesoncu
Language
C++ (G++ 4.6.4)
Score
100
Code Size
819 Byte
Status
AC
Exec Time
366 ms
Memory
944 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:19:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:21:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Judge Result
Set Name
Set01
Set02
Set03
Set04
Set05
Set06
Set07
Set08
Set09
Set10
Set11
Set12
Set13
Set14
Set15
Set16
Set17
Set18
Set19
Set20
Score / Max Score
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
Status
Set Name
Test Cases
Set01
01
Set02
02
Set03
03
Set04
04
Set05
05
Set06
06
Set07
07
Set08
08
Set09
09
Set10
10
Set11
11
Set12
12
Set13
13
Set14
14
Set15
15
Set16
16
Set17
17
Set18
18
Set19
19
Set20
20
Case Name
Status
Exec Time
Memory
01
AC
21 ms
804 KB
02
AC
22 ms
808 KB
03
AC
20 ms
796 KB
04
AC
20 ms
804 KB
05
AC
23 ms
804 KB
06
AC
23 ms
932 KB
07
AC
20 ms
796 KB
08
AC
21 ms
808 KB
09
AC
21 ms
804 KB
10
AC
22 ms
796 KB
11
AC
23 ms
924 KB
12
AC
24 ms
928 KB
13
AC
24 ms
800 KB
14
AC
24 ms
928 KB
15
AC
27 ms
808 KB
16
AC
38 ms
804 KB
17
AC
195 ms
928 KB
18
AC
277 ms
944 KB
19
AC
366 ms
932 KB
20
AC
107 ms
804 KB