Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
hash....超了内存,怎么减少内存呀。。#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <numeric> using namespace std; bool t[40005][40005]; int r[1003],c[1003]; int main(){ int n; while (cin>>n){ memset(t,0,sizeof(t)); memset(r,0,sizeof(r)); memset(c,0,sizeof(c)); if (0==n) break; for (int i=0;i<n;i++){ cin>>r[i]>>c[i]; t[r[i]+20000][c[i]+20000]=1; } int num=0; for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (i==j) continue; int x1=r[i]+(c[i]-c[j]); int y1=c[i]-(r[i]-r[j]); int x2=r[j]+(c[i]-c[j]); int y2=c[j]-(r[i]-r[j]); int x3=r[i]-(c[i]-c[j]); int y3=c[i]+(r[i]-r[j]); int x4=r[j]-(c[i]-c[j]); int y4=c[j]+(r[i]-r[j]); if ((1==t[x1+20000][y1+20000])&&(1==t[x2+20000][y2+20000])) num++; if ((1==t[x3+20000][y3+20000])&&(1==t[x4+20000][y4+20000])) num++; } } cout<<num/8<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator