Submission #148555

# Submission time Handle Problem Language Result Execution time Memory
148555 2019-09-01T04:39:08 Z bitKOIn(#3612, gs15120, phsongys) FunctionCup Museum (FXCUP4_museum) C++17
0 / 100
5 ms 384 KB
#include "museum.h"
#include <bits/stdc++.h>
#define PI 3.1415926535897932384626
using namespace std;

struct vec
{
    long double x,y;
    bool operator ==(const vec &a) const{
        return x==a.x&&y==a.y;
    }
    bool operator <(const vec &a) const{
        if(a.x!=x) return x<a.x;
        return y<a.y;
    }
    vec operator +(const vec &a) const{
        return {x+a.x,y+a.y};
    }
    vec operator *(const long double &a) const{
        return {x*a,y*a};
    }
    vec operator -(const vec &a) const{
        return {x-a.x,y-a.y};
    }
    vec operator /(const long double &a) const{
        return {x/a,y/a};
    }
    long double len() const{
        return sqrt(x*x+y*y);
    }
    long double dot(const vec &a) const{
        return x*a.x+y*a.y;
    }
    long double crs(const vec &a) const{
        return x*a.y-y*a.x;
    }
    vec proj(const vec &a) const{
        return (a/a.len())*(*this).dot(a)/a.len();
    }
};

struct P
{

    int x,y,z;
    bool operator <(const P &a) const{

        return y>a.y;
    }
};


bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}

bool asd(P a,P b)
{
    if(a.z!=b.z)
    return a.z<b.z;
    return a.x<b.x;
}

bool asdf(P a,P b)
{
    if(a.y!=b.y)
    return a.y<b.y;
    return a.z<b.z;
}

long long x,y,z,mod=1000000007;
vector<int> v[1];
int i,n,m,k,a,d,b,c,dx[10]={1,0,-1,0},dy[10]={0,1,0,-1};
int e;
int o[1];
int l[1];
int par[1];
int j[1];

//stack<int> s;
set<int> s;
queue<int> q,q1;
P u[211111];
char r[1];
//string r,r1;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();


long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int a = B.size();
	for(int h=0;h<a;h++)
        u[h+1].x=B[h];
    for(int h=0;h<a;h++)
        u[h+1].x=T[h];
    for(int h=0;h<a;h++)
        u[h+1].x=G[h];
	sort(u+1,u+a+1,as);
    n=1,m=1;
    for(int t=1;t<=a+1;t++)
    {
        if(u[t].x!=u[n].x||u[t].y!=u[n].y)
        {
            x-=(long long)(t-n)*(t-n-1)/2;
            n=t;
        }
        if(u[t].x!=u[m].x)
        {
            x+=(long long)(t-m)*(t-m-1)/2;
            m=t;
        }
    }
    n=1,m=1;
    sort(u+1,u+a+1,asd);
    for(int t=1;t<=a+1;t++)
    {
        if(u[t].x!=u[n].x||u[t].z!=u[n].z)
        {
            x-=(long long)(t-n)*(t-n-1)/2;
            n=t;
        }
        if(u[t].z!=u[m].z)
        {
            x+=(long long)(t-m)*(t-m-1)/2;
            m=t;
        }
    }
    n=1,m=1;
    sort(u+1,u+a+1,asdf);
    for(int t=1;t<=a+1;t++)
    {
        if(u[t].y!=u[n].y||u[t].z!=u[n].z)
        {
            x-=(long long)(t-n)*(t-n-1)/2;
            n=t;
        }
        if(u[t].y!=u[m].y)
        {
            x+=(long long)(t-m)*(t-m-1)/2;
            m=t;
        }
    }
    n=1;
    for(int t=1;t<=a+1;t++)
    {
        if(u[t].y!=u[n].y||u[t].z!=u[n].z||u[t].x!=u[n].x)
        {
            x+=(long long)(t-n)*(t-n-1)/2*3;
            n=t;
        }
    }
    //printf("%lld",x);
	return x;



}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:107:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int h=0;h<a;h++)
     ^~~
museum.cpp:109:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  sort(u+1,u+a+1,as);
  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -