Submission #810865

# Submission time Handle Problem Language Result Execution time Memory
810865 2023-08-06T16:56:27 Z ma_moutahid Ideal city (IOI12_city) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using ll =long long;
#define int ll
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
//#define int ll
using namespace std;



int DistanceSum(int n,int *X,int *Y){
    map<int,set<int>>x;
    map<int,set<int>>y;
    map<pi,pi>pos;
    int mod=1e9;
    for(int i=0;i<n;i++){
        x[X[i]].insert(Y[i]);
        y[Y[i]].insert(X[i]);
    }
    for(auto &itr:x){
        int xpos=itr.first;
        int p=0;
        for(auto i=itr.second.begin();i!=itr.second.end();i++){
            pos[make_pair(xpos,*i)].second=p;
            p++;
        }
    }
    for(auto &itr:y){
        int ypos=itr.first;
        int p=0;
        for(auto i=itr.second.begin();i!=itr.second.end();i++){
            pos[make_pair(*i,ypos)].first=p;
            p++;
        }
    }

    int result=0;
    for (auto& itr:x){
        int tbc=0;
        int count=0;
        int dist=0;
        int xpos=itr.first;
        for(auto p:itr.second){
            int total=y[p].size();
            int left=pos[make_pair(xpos,p)].second;
            int right=total-1-left;
            int temp=right*(right+1)/2 + left*(left+1)/2;
            dist+= dist;
            dist+=count;
            dist+=temp;
            tbc+=temp;
            count+=total;
            dist%=mod;
            tbc%=mod;
        }
        result-=tbc;
        result+=dist;
        result+=mod;
        result%=mod;


    }
    for (auto t=x.cbegin();t!=x.cend();t++){
        auto &itr=*t;
        int count=0;
        int dist=0;
        int xpos=itr.first;
        int tbc=0;
        for(auto p:itr.second){
            int total=y[p].size();
            int left=pos[make_pair(xpos,p)].second;
            int right=total-1-left;
            int temp=right*(right+1)/2 + left*(left+1)/2;
            dist+= dist;
            dist+=count;
            dist+=temp;
            tbc+=temp;
            count+=total-1;
            dist%=mod;
            tbc%=mod;
        }
        result-=tbc;
        result+=dist;
        result+=mod;
        result%=mod;
    }
    return result;

}

Compilation message

/usr/bin/ld: /tmp/ccRrjaVt.o: in function `main':
grader.cpp:(.text.startup+0x104): undefined reference to `DistanceSum(int, int*, int*)'
collect2: error: ld returned 1 exit status