Submission #69624

# Submission time Handle Problem Language Result Execution time Memory
69624 2018-08-21T10:17:02 Z Abelyan Ideal city (IOI12_city) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int  MOD = 1000000000;

struct ci{
    LL x,y;
    int nea[4]={-1,-1,-1,-1};
}inf[2222];
 
LL n,sum;
LL x[2222],y[2222];
map<pll,int> mp;
 
queue<int> qi,qd;
bool used[2222];
 
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
 
void bfs(int v,int d){
    qi.push(v);
    qd.push(d);
    used[v]=true;
    while(!qi.empty()){
        int pi=qi.front(); qi.pop();
        int pd=qd.front(); qd.pop();
        sum=(sum+pd)%(MOD*2);
 
        for(int i=0;i<4;i++){
            if(inf[pi].nea[i]!=-1 && !used[inf[pi].nea[i]]){
                qi.push(inf[pi].nea[i]);
                qd.push(pd+1);
                used[inf[pi].nea[i]]=1;
            }
        }
    }
}
 
int DistanceSum(int N,int *X,int *Y){
    n=N;
    for(int i=0;i<N;i++) x[i]=X[i];
    for(int i=0;i<N;i++) y[i]=Y[i];
 
    for(int i=0;i<n;i++) mp.insert({{x[i],y[i]},i});
    for(int i=0;i<n;i++){
        inf[i].x=x[i];
        inf[i].y=y[i];
        for(int j=0;j<4;j++){
            int nx=x[i]+dx[j];
            int ny=y[i]+dy[j];
 
            map<pll,int>::iterator it=mp.find({nx,ny});
            if(it!=mp.end()) inf[i].nea[j]=it->second;
        }
    }
 
    if(n<=2000){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++) used[j]=0;
            bfs(i,0);
        }
 
        return sum/2;
    }
 
    return 0;
}

Compilation message

city.cpp:7:5: error: 'LL' does not name a type
     LL x,y;
     ^~
city.cpp:11:1: error: 'LL' does not name a type
 LL n,sum;
 ^~
city.cpp:12:1: error: 'LL' does not name a type
 LL x[2222],y[2222];
 ^~
city.cpp:13:5: error: 'pll' was not declared in this scope
 map<pll,int> mp;
     ^~~
city.cpp:13:5: note: suggested alternative: 'kill'
 map<pll,int> mp;
     ^~~
     kill
city.cpp:13:12: error: template argument 1 is invalid
 map<pll,int> mp;
            ^
city.cpp:13:12: error: template argument 3 is invalid
city.cpp:13:12: error: template argument 4 is invalid
city.cpp: In function 'void bfs(int, int)':
city.cpp:28:9: error: 'sum' was not declared in this scope
         sum=(sum+pd)%(MOD*2);
         ^~~
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:41:5: error: 'n' was not declared in this scope
     n=N;
     ^
city.cpp:42:26: error: 'x' was not declared in this scope
     for(int i=0;i<N;i++) x[i]=X[i];
                          ^
city.cpp:43:26: error: 'y' was not declared in this scope
     for(int i=0;i<N;i++) y[i]=Y[i];
                          ^
city.cpp:45:29: error: request for member 'insert' in 'mp', which is of non-class type 'int'
     for(int i=0;i<n;i++) mp.insert({{x[i],y[i]},i});
                             ^~~~~~
city.cpp:45:38: error: 'x' was not declared in this scope
     for(int i=0;i<n;i++) mp.insert({{x[i],y[i]},i});
                                      ^
city.cpp:45:43: error: 'y' was not declared in this scope
     for(int i=0;i<n;i++) mp.insert({{x[i],y[i]},i});
                                           ^
city.cpp:47:16: error: 'struct ci' has no member named 'x'
         inf[i].x=x[i];
                ^
city.cpp:47:18: error: 'x' was not declared in this scope
         inf[i].x=x[i];
                  ^
city.cpp:48:16: error: 'struct ci' has no member named 'y'
         inf[i].y=y[i];
                ^
city.cpp:48:18: error: 'y' was not declared in this scope
         inf[i].y=y[i];
                  ^
city.cpp:53:17: error: 'pll' was not declared in this scope
             map<pll,int>::iterator it=mp.find({nx,ny});
                 ^~~
city.cpp:53:17: note: suggested alternative: 'kill'
             map<pll,int>::iterator it=mp.find({nx,ny});
                 ^~~
                 kill
city.cpp:53:24: error: template argument 1 is invalid
             map<pll,int>::iterator it=mp.find({nx,ny});
                        ^
city.cpp:53:24: error: template argument 3 is invalid
city.cpp:53:24: error: template argument 4 is invalid
city.cpp:53:36: error: expected initializer before 'it'
             map<pll,int>::iterator it=mp.find({nx,ny});
                                    ^~
city.cpp:53:54: error: expected primary-expression before ')' token
             map<pll,int>::iterator it=mp.find({nx,ny});
                                                      ^
city.cpp:54:16: error: 'it' was not declared in this scope
             if(it!=mp.end()) inf[i].nea[j]=it->second;
                ^~
city.cpp:54:16: note: suggested alternative: 'i'
             if(it!=mp.end()) inf[i].nea[j]=it->second;
                ^~
                i
city.cpp:54:23: error: request for member 'end' in 'mp', which is of non-class type 'int'
             if(it!=mp.end()) inf[i].nea[j]=it->second;
                       ^~~
city.cpp:50:17: warning: unused variable 'nx' [-Wunused-variable]
             int nx=x[i]+dx[j];
                 ^~
city.cpp:51:17: warning: unused variable 'ny' [-Wunused-variable]
             int ny=y[i]+dy[j];
                 ^~
city.cpp:64:16: error: 'sum' was not declared in this scope
         return sum/2;
                ^~~