Submission #1338819

#TimeUsernameProblemLanguageResultExecution timeMemory
1338819edl0231Handcrafted Gift (IOI20_gift)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "gift.h"
#include "grader.cpp"
using namespace std;

int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
    vector<pair<int, int>> v;
    for (int i = 0; i < r; i++)
    {
        if (x[i] == 1) {v.emplace_back(a[i], b[i]);}
    }
    sort(v.begin(), v.end());
    vector<pair<int, int>> intervals;
    int st = -1, curr = -1;
//    for (auto i : v) cout << i.first << ' ' << i.second;
    for (auto i : v)
    {
        if (st == -1) {st = i.first, curr = i.second; continue;}
        if (i.first > curr) {intervals.emplace_back(st, curr); st = i.first, curr = i.second; continue;}
        curr = i.second;
    }
    if (st != -1) intervals.emplace_back(st, curr);
//    for (auto i : intervals) cout << i.first << ' ' << i.second << '\n';
    
    vector<int> w(n);
    int ind = 0, ct = 0;
    for (auto i : intervals)
    {
        while (ind < i.first) w[ind] = ct, ind++, ct++;
        for (int j = i.first; j <= i.second; j++) w[j] = ct;
        ind = i.second + 1, ct++;
    }
    for (; ind < n; ind++) w[ind++] = ct++;
//    for (auto i : w) cout << i << ' ';
    for (int i = 0; i < r; i++)
    {
        if (x[i] == 1) continue;
        if (w[a[i]] == w[b[i]]) return 0;
    }
    string s = "";
    for (int i = 0; i < n; i++)
    {
        if (w[i] & 1) s += 'R';
        else s += 'B';
    }
    craft(s);
    return 1;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccmK2ei2.o: in function `craft(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
grader.cpp:(.text+0x90): multiple definition of `craft(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'; /tmp/cc3GRX71.o:gift.cpp:(.text+0x500): first defined here
/usr/bin/ld: /tmp/ccmK2ei2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3GRX71.o:gift.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status