|
|
back to boardCommon BoardI don't know C++. See program. i want thet my program didn't read from file #include <fstream.h> #include <search.h> ifstream in("input.txt"); ofstream out("output.txt"); const maxn=15000; struct TStar { int x, y; int operator < (const TStar &s) const { return x<s.x || (x==s.x && y<s.y); } void input() { in>>x>>y; } }; TStar stars[maxn]; int far counts[maxn]={0}; int far stats[maxn]={0}; int sortf( const void *a, const void *b) { const TStar &sa=*(const TStar *)a; const TStar &sb=*(const TStar *)b; return sa<sb ? -1 : sb<sa ? 1 : 0; } int main() { int n; in>>n; for(int i=0;i<n;i++) stars[i].input(); qsort((void *)stars, n, sizeof(stars[0]), sortf); in.close(); in.open("input.txt"); in>>n; for(i=0;i<n;i++) { TStar s; s.input(); int l=0, r=n-1, c=0; while(l!=r) { int o=(l+r)/2; if(stars[o]<s) { c+=counts[o]; l=o+1; } else { counts[o]++; r=o; } } stats[c]++; } for(i=0;i<n;i++) out<<stats[i]<<endl; return 0; } |
|
|