Submission #81158

# Submission time Handle Problem Language Result Execution time Memory
81158 2018-10-24T02:49:13 Z KemLove Ancient Books (IOI17_books) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pt;
typedef pair<int, ii> iii;
typedef vector<int> vi;

#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define FORD(i, l, r) for(int i = l; i >= r; --i)
#define REP(i, r) for(int i = 0; i < int(r); ++i)
#define REPD(i, r) for(int i = int(r)-1; i >= 0; --i)
#define fi first
#define se second
#define x first
#define y second
#define sz size
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mk make_pair

const int Nmax = 2e6 + 10;
const ll inf = 1e9;
const db _eps = 1e-15;

vi a[Nmax];
int n, s, last, startlast;
ll sum;
bool avail[Nmax];

void visit(int u) {
    last = u;
    avail[u] = true;
    REP(i, a[u].sz()) {
        int v = a[u][i];
        sum += 1LL * abs(v - u);
        if (avail[v] == false) {
            visit(v);
        }
    }
}

ll minimum_walk(vi p, int s) {
    s++; n = p.sz();
    FOR(i, 1, n) {
        a[i].push_back(p[i-1] + 1);
    }
    startlast = s;
    FOR(i, s, n) {
        if (avail[i]) continue;
        sum += abs(i - startlast);
        visit(i);
        startlast = i;
    }
    FORD(i, s - 1, 1) {
        if (avail[i]) continue;
        sum += abs(i - startlast);
        visit(i);
        startlast = i;
    }
    return 1LL * abs(s - startlast) + sum;
}

int main() {
    /*vector <int> p;
    //freopen("books.inp", "r", stdin);
    cin >> n >> s;
    FOR(i, 1, n) {
        int x;
        cin >> x;
        p.push_back(x);
    }*/
    //cout << minimum_walk(p, s);
}

Compilation message

/tmp/ccgLbWpx.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2geR4Y.o:books.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status