답안 #39522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39522 2018-01-16T09:19:52 Z smu201111192 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstdio>
#include <cassert>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
map<pair<int,int>,int> mp;
const int dy[4]={0,0,1,-1};
const int dx[4]={1,-1,0,0};
vector<int> adj[4005];
const int mod = 1000000000;
int dist[4005];
int convert[4005];
void addEdge(int u,int v){
    adj[u].push_back(v);
    adj[v].push_back(u);
}
int bfs(int here,int n){
    memset(dist,-1,sizeof(dist));
    dist[here] = 0;
    queue<int> q;
    q.push(here);
    while(!q.empty()){
        int here = q.front(); q.pop();
        for(int i=0;i<adj[here].size();i++){
            int there = adj[here][i];
            if(dist[there] == -1){
                dist[there] = dist[here] + 1;
                q.push(there);
            }
        }
    }
    int ret = 0;
    for(int i = 0;i<4000;i++){
        //if(i > here){
            ret += max(dist[i],0);
            ret %= mod;
        //}
    }
    return ret;
}
int DistanceSum(int N, int *X, int *Y) {
    for(int i=0;i<N;i++){
        mp[make_pair(Y[i],X[i])];
    }
    int id = 0;
    for(auto it = mp.begin();it!=mp.end();it++){
        it->second = ++id;
    }
    for(int i=0;i<N;i++){
        int x = X[i];
        int y = Y[i];
        for(int k=0;k<4;k++){
            int ny = y + dy[k];
            int nx = x + dx[k];
            if(mp.find(make_pair(ny,nx)) != mp.end()){
                addEdge(mp[make_pair(y,x)],mp[make_pair(ny,nx)]);
            }
        }
    }
    int tot = 0;
    for(int i=1;i<=N;i++){
        tot += bfs(i,N);
        tot %= mod;
    }
    
    return tot;
    
}

Compilation message

garden.cpp: In function 'int bfs(int, int)':
garden.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adj[here].size();i++){
                     ~^~~~~~~~~~~~~~~~~
/tmp/ccn6UIlA.o: In function `main':
grader.cpp:(.text.startup+0x38): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status