Submission #148609

# Submission time Handle Problem Language Result Execution time Memory
148609 2019-09-01T04:46:04 Z bitKOIn(#3612, gs15120, phsongys) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
189 ms 7532 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;
    if(a.z!=b.z)
    return a.z<b.z;
    return a.x<b.x;
}

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].y=T[h];
    for(int h=0;h<a;h++)
        u[h+1].z=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;
            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:109:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int h=0;h<a;h++)
     ^~~
museum.cpp:111: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 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 11 ms 640 KB Output is correct
12 Correct 25 ms 1536 KB Output is correct
13 Correct 56 ms 2548 KB Output is correct
14 Correct 81 ms 3312 KB Output is correct
15 Correct 120 ms 4848 KB Output is correct
16 Correct 126 ms 7532 KB Output is correct
17 Correct 151 ms 7404 KB Output is correct
18 Correct 176 ms 7528 KB Output is correct
19 Correct 189 ms 7528 KB Output is correct
20 Correct 188 ms 7524 KB Output is correct