QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#882509 | #9879. ReTravel | AllenJYL | WA | 31ms | 6528kb | C++14 | 2.6kb | 2025-02-05 08:44:07 | 2025-02-05 08:44:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define all(_array) (_array).begin(),(_array).end()
#define msp(_array) memset(_array,0x3f,sizeof _array)
#define ms0(_array) memset(_array,0,sizeof _array)
#define msn(_array) memset(_array,-1,sizeof _array)
#define mc(_tar,_array) memcpy(_tar,_array,sizeof _tar)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TAK cout<<"TAK"<<endl
#define NIE cout<<"NIE"<<endl
#define OK cerr<<"OK"<<endl
#define pii pair<int,int>
#define endl '\n'
bool bg_memory;
mt19937 rnd(time(0));
int Case=1;
const int mod=1e9+7;
const int inf=2147483647;
const int bs=233;
const double eps=1e-6;
const int N=5e2+7,M=1e5+7;
template<class _t1,class _t2>inline void cmax(_t1 &a,_t2 b){a=a<b?b:a;}
template<class _t1,class _t2>inline void cmin(_t1 &a,_t2 b){a=a>b?b:a;}
inline int qp(int a,int b,int p=mod){int res=1;while(b){if(b&1)res=1ll*res*a%p;a=1ll*a*a%p;b>>=1;}return res;}
inline int sqrt(int x,int r){int l=0,ans=0;while(l<=r){if(1ll*mid*mid<=x) ans=mid,l=mid+1;else r=mid-1;}return ans;}
int n;
int x[N],y[N];
struct node{
int dp,x,y;
}f[N][N];
void Main(){
cin>>n;
for(int i=1;i<=n;i++) cin>>x[i]>>y[i],f[i][i].x=x[i],f[i][i].y=y[i];
for(int i=2;i<=n+1;i++){
for(int j=0;j+i-1<=n;j++){
f[j][j+i-1].x=min(f[j+1][j+i-1].x,x[j]);
f[j][j+i-1].y=min(f[j+1][j+i-1].y,y[j]);
f[j][j+i-1].dp=inf;
for(int k=j;k<j+i-1;k++){
cmin(f[j][j+i-1].dp,f[j][k].dp+f[k+1][j+i-1].dp
+f[j][k].x+f[k+1][j+i-1].x
+f[j][k].y+f[k+1][j+i-1].y
-2*f[j][j+i-1].x-2*f[j][j+i-1].y);
}
}
}
cout<<f[0][n].dp<<endl;
return;
}
string RdFile="";
bool en_memory;
signed main(){
auto bg_clock=chrono::high_resolution_clock::now();
#ifdef ONLINE_JUDGE
// freopen((RdFile+".in").c_str(),"r",stdin);
// freopen((RdFile+".out").c_str(),"w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cin>>Case;
while(Case--) Main();
auto en_clock=chrono::high_resolution_clock::now();
auto duration_clock=chrono::duration_cast<chrono::microseconds>(en_clock-bg_clock);
double duration_count=duration_clock.count()*0.001;
double memory_used=(&en_memory-&bg_memory)/1024.0/1024;
// cerr<<"Time:"<<duration_count<<"ms"<<endl;
// cerr<<"Memory: "<<memory_used<<"MB"<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
2 3 3 1 2
output:
6
result:
ok "6"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 2 2 3 3 1 3
output:
7
result:
ok "7"
Test #3:
score: -100
Wrong Answer
time: 31ms
memory: 6528kb
input:
500 906691059 413653999 813847339 955892128 451585301 43469773 278009742 548977048 521760889 434794718 985946604 841597326 891047768 325679554 511742081 384452587 626401695 957413342 975078788 234551094 541903389 149544006 302621084 150050891 811538590 101823753 663968655 858351976 268979133 9768326...
output:
-2077130627
result:
wrong answer 1st words differ - expected: '202616034783', found: '-2077130627'