Submission #122229

# Submission time Handle Problem Language Result Execution time Memory
122229 2019-06-27T21:45:37 Z Osama_Alkhodairy Ideal city (IOI12_city) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//~ #include "grader.cpp"
using namespace std;

const ll N = 100001;

ll n, wr[N], wc[N], mod = 1e9 + 7;
set <ll> r[N], c[N];
vector <pair <ll, ll> > a;
map <pair <ll, ll>, ll> mpr, mpc;
ll cntr, cntc, ans;

void addr(ll x, ll y){
    r[x].insert(y);
    r[y].insert(x);
}
void addc(ll x, ll y){
    c[x].insert(y);
    c[y].insert(x);
}
void setr(ll row, ll col1, ll col2){
    ll id = cntr++;
    wr[id] = col2 - col1 + 1;
    for(ll col = col1 ; col <= col2 ; col++){
        if(mpr.find(make_pair(row - 1, col)) != mpr.end()){
            addr(id, mpr[make_pair(row - 1, col)]);
        }
        mpr[make_pair(row, col)] = id;
    }
}
void setc(ll col, ll row1, ll row2){
    ll id = cntc++;
    wc[id] = row2 - row1 + 1;
    for(ll row = row1 ; row <= row2 ; row++){
        if(mpc.find(make_pair(row, col - 1)) != mpc.end()){
            addc(id, mpc[make_pair(row, col - 1)]);
        }
        mpc[make_pair(row, col)] = id;
    }
}
void gor(ll l, ll r){
    for(ll i = l ; i < r ; i++){
        ll j = i;
        while(j + 1 < r && a[j + 1].second == a[j].second + 1) j++;
        setr(a[i].first, a[i].second, a[j].second);
        i = j;
    }
}
void goc(ll l, ll r){
    for(ll i = l ; i < r ; i++){
        ll j = i;
        while(j + 1 < r && a[j + 1].first == a[j].first + 1) j++;
        setc(a[i].second, a[i].first, a[j].first);
        i = j;
    }
}
void dfsr(ll node, ll pnode){
    for(auto &i : r[node]){
        if(i == pnode) continue;
        dfsr(i, node);
        ans = (ans + 1LL * wr[i] * (n - wr[i])) % mod;
        wr[node] += wr[i];
    }
}
void dfsc(ll node, ll pnode){
    for(auto &i : c[node]){
        if(i == pnode) continue;
        dfsc(i, node);
        ans = (ans + 1LL * wc[i] * (n - wc[i])) % mod;
        wc[node] += wc[i];
    }
}
int DistanceSum(ll N, ll *X, ll *Y) {
    n = N;
    for(ll i = 0 ; i < n ; i++){
        a.push_back(make_pair(X[i], Y[i]));
    }
    sort(a.begin(), a.end());
    for(ll i = 0 ; i < n ; i++){
        ll j = i;
        while(j < n && a[j].first == a[i].first) j++;
        gor(i, j);
        i = j - 1;
    }
    sort(a.begin(), a.end(), [&](pair <ll, ll> l, pair <ll, ll> r){
        return make_pair(l.second, l.first) < make_pair(r.second, r.first);
    });
    for(ll i = 0 ; i < n ; i++){
        ll j = i;
        while(j < n && a[j].second == a[j].second) j++;
        goc(i, j);
        i = j - 1;
    }
    dfsr(0, -1);
    dfsc(0, -1);
    return ans;
}

Compilation message

city.cpp:5:7: error: 'll' does not name a type
 const ll N = 100001;
       ^~
city.cpp:7:1: error: 'll' does not name a type
 ll n, wr[N], wc[N], mod = 1e9 + 7;
 ^~
city.cpp:8:6: error: 'll' was not declared in this scope
 set <ll> r[N], c[N];
      ^~
city.cpp:8:8: error: template argument 1 is invalid
 set <ll> r[N], c[N];
        ^
city.cpp:8:8: error: template argument 2 is invalid
city.cpp:8:8: error: template argument 3 is invalid
city.cpp:8:12: error: 'N' was not declared in this scope
 set <ll> r[N], c[N];
            ^
city.cpp:8:18: error: 'N' was not declared in this scope
 set <ll> r[N], c[N];
                  ^
city.cpp:9:15: error: 'll' was not declared in this scope
 vector <pair <ll, ll> > a;
               ^~
city.cpp:9:19: error: 'll' was not declared in this scope
 vector <pair <ll, ll> > a;
                   ^~
city.cpp:9:21: error: template argument 1 is invalid
 vector <pair <ll, ll> > a;
                     ^
city.cpp:9:21: error: template argument 2 is invalid
city.cpp:9:23: error: template argument 1 is invalid
 vector <pair <ll, ll> > a;
                       ^
city.cpp:9:23: error: template argument 2 is invalid
city.cpp:10:12: error: 'll' was not declared in this scope
 map <pair <ll, ll>, ll> mpr, mpc;
            ^~
city.cpp:10:16: error: 'll' was not declared in this scope
 map <pair <ll, ll>, ll> mpr, mpc;
                ^~
city.cpp:10:18: error: template argument 1 is invalid
 map <pair <ll, ll>, ll> mpr, mpc;
                  ^
city.cpp:10:18: error: template argument 2 is invalid
city.cpp:10:21: error: 'll' was not declared in this scope
 map <pair <ll, ll>, ll> mpr, mpc;
                     ^~
city.cpp:10:23: error: template argument 1 is invalid
 map <pair <ll, ll>, ll> mpr, mpc;
                       ^
city.cpp:10:23: error: template argument 2 is invalid
city.cpp:10:23: error: template argument 3 is invalid
city.cpp:10:23: error: template argument 4 is invalid
city.cpp:11:1: error: 'll' does not name a type
 ll cntr, cntc, ans;
 ^~
city.cpp:13:11: error: variable or field 'addr' declared void
 void addr(ll x, ll y){
           ^~
city.cpp:13:11: error: 'll' was not declared in this scope
city.cpp:13:17: error: 'll' was not declared in this scope
 void addr(ll x, ll y){
                 ^~
city.cpp:17:11: error: variable or field 'addc' declared void
 void addc(ll x, ll y){
           ^~
city.cpp:17:11: error: 'll' was not declared in this scope
city.cpp:17:17: error: 'll' was not declared in this scope
 void addc(ll x, ll y){
                 ^~
city.cpp:21:11: error: variable or field 'setr' declared void
 void setr(ll row, ll col1, ll col2){
           ^~
city.cpp:21:11: error: 'll' was not declared in this scope
city.cpp:21:19: error: 'll' was not declared in this scope
 void setr(ll row, ll col1, ll col2){
                   ^~
city.cpp:21:28: error: 'll' was not declared in this scope
 void setr(ll row, ll col1, ll col2){
                            ^~
city.cpp:31:11: error: variable or field 'setc' declared void
 void setc(ll col, ll row1, ll row2){
           ^~
city.cpp:31:11: error: 'll' was not declared in this scope
city.cpp:31:19: error: 'll' was not declared in this scope
 void setc(ll col, ll row1, ll row2){
                   ^~
city.cpp:31:28: error: 'll' was not declared in this scope
 void setc(ll col, ll row1, ll row2){
                            ^~
city.cpp:41:10: error: variable or field 'gor' declared void
 void gor(ll l, ll r){
          ^~
city.cpp:41:10: error: 'll' was not declared in this scope
city.cpp:41:16: error: 'll' was not declared in this scope
 void gor(ll l, ll r){
                ^~
city.cpp:49:10: error: variable or field 'goc' declared void
 void goc(ll l, ll r){
          ^~
city.cpp:49:10: error: 'll' was not declared in this scope
city.cpp:49:16: error: 'll' was not declared in this scope
 void goc(ll l, ll r){
                ^~
city.cpp:57:11: error: variable or field 'dfsr' declared void
 void dfsr(ll node, ll pnode){
           ^~
city.cpp:57:11: error: 'll' was not declared in this scope
city.cpp:57:20: error: 'll' was not declared in this scope
 void dfsr(ll node, ll pnode){
                    ^~
city.cpp:65:11: error: variable or field 'dfsc' declared void
 void dfsc(ll node, ll pnode){
           ^~
city.cpp:65:11: error: 'll' was not declared in this scope
city.cpp:65:20: error: 'll' was not declared in this scope
 void dfsc(ll node, ll pnode){
                    ^~
city.cpp:73:17: error: 'll' was not declared in this scope
 int DistanceSum(ll N, ll *X, ll *Y) {
                 ^~
city.cpp:73:23: error: 'll' was not declared in this scope
 int DistanceSum(ll N, ll *X, ll *Y) {
                       ^~
city.cpp:73:27: error: 'X' was not declared in this scope
 int DistanceSum(ll N, ll *X, ll *Y) {
                           ^
city.cpp:73:30: error: 'll' was not declared in this scope
 int DistanceSum(ll N, ll *X, ll *Y) {
                              ^~
city.cpp:73:34: error: 'Y' was not declared in this scope
 int DistanceSum(ll N, ll *X, ll *Y) {
                                  ^
city.cpp:73:35: error: expression list treated as compound expression in initializer [-fpermissive]
 int DistanceSum(ll N, ll *X, ll *Y) {
                                   ^