Code: Select all
for (i=0; i<npoint; i++)
for (j=0; j<npoint; j++)
clr(i,j);
Moderator: Board moderators
Code: Select all
for (i=0; i<npoint; i++)
for (j=0; j<npoint; j++)
clr(i,j);
Code: Select all
for(i=0;i<n;i++)
for(j=i+1;j<n;j++) {
if( V[i].x >= V[j].x || V[i].y >=V[j].y) continue;
if( A[V[i].x][V[j].y] && A[V[i].y][V[j].x] )
ans++;
}
Code: Select all
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int MAXN = 5000;
struct pt {
int x, y;
pt( int nx = 0, int ny = 0 ) : x( nx ), y( ny ) {}
friend bool operator<( const pt& A, const pt& B ) {
if ( A.x != B.x ) return ( A.x < B.x );
return ( A.y < B.y );
}
};
char ima[MAXN][MAXN];
char cookie = 0;
int main()
{
int t; scanf( "%d", &t );
for( int t_case = 0; t_case < t; ++t_case ) {
int n; scanf( "%d", &n );
vector< pt > P( n );
map< int, int > X, Y;
for( int i = 0; i < n; ++i ) {
scanf( "%d%d", &P[i].x, &P[i].y );
X[P[i].x] = 3;
Y[P[i].y] = 4;
}
{
int i = 0;
for( map< int, int >::iterator it = X.begin(); it != X.end(); ++it, ++i )
it->second = i;
}
{
int i = 0;
for( map< int, int >::iterator it = Y.begin(); it != Y.end(); ++it, ++i )
it->second = i;
}
++cookie;
for( int i = 0; i < n; ++i ) {
P[i].x = X[P[i].x];
P[i].y = Y[P[i].y];
ima[P[i].x][P[i].y] = cookie;
}
sort( P.begin(), P.end() );
int cnt = 0;
for( short i = 0; i < n; ++i )
for( short j = i + 1; j < n; ++j )
cnt += ( P[i].x < P[j].x && P[i].y < P[j].y && ima[P[i].x][P[j].y] == cookie && ima[P[j].x][P[i].y] == cookie );
printf( "Case %d: %d\n", t_case + 1, cnt );
}
return 0;
}
Code: Select all
void wait(int n){
int i,j,k;
int dummy=0;
for(i=0;i<n;i++){
for(j=0;j<10000;j++){
for(k=0;k<1435;k++){
dummy++;
}
}
}
}