去年的对拍noip上用不了...
不知道是不是机子的问题...换了一种对拍。
以洛谷11月月赛T2为例。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define LL long long using namespace std; int n; int h[320],vis[320]; LL ans; void dfs(int now,int a,LL scor) { if(a==n) { ans=max(ans,scor); return ; } for(int i=1;i<=n;i++) { if(vis[i]) continue; vis[i]=true; dfs(i,a+1,scor+(h[now]-h[i])*(h[now]-h[i])); vis[i]=false; } } int main() { freopen("rand.txt","r",stdin); freopen("baoli.txt","w",stdout); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&h[i]); dfs(0,0,0); cout<<ans<<endl; return 0; }
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define LL long long using namespace std; int n; int L,R; int h[320]; LL ans; int main() { freopen("rand.txt","r",stdin); freopen("my.txt","w",stdout); scanf("%d",&n);L=0;R=n; for(int i=1;i<=n;i++) scanf("%d",&h[i]); sort(h,h+n+1); while(L<R) { ans=ans+(h[R]-h[L])*(h[R]-h[L]); L++; ans=ans+(h[R]-h[L])*(h[R]-h[L]); R--; } cout<<ans<<endl; return 0; }
#include<iostream> #include<cstring> #include<ctime> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; int main() { freopen("rand.txt","w",stdout); srand(time(0)); int n;n=rand()%5+1; cout<<n<<endl; for(int i=1;i<=n;i++) { int x;x=rand()%100+2; cout<<x<<" "; } return 0; }
#include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; int main() { while(1) { system("rand.exe"); system("baoli.exe"); system("my.exe"); if(system("fc baoli.txt my.txt ")) while(1); } return 0; }
要写cstdlib
这四个程序