Submission #385466

#TimeUsernameProblemLanguageResultExecution timeMemory
385466taulantHandcrafted Gift (IOI20_gift)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; void craft(string s); int construct(int n, int r, int a[], int b[], int x[]){ vector<pii> one, two; for(int i = 0; i < r; ++i){ if(x[i] == 1) one.push_back({a[i], b[i]}); if(x[i] == 2) two.push_back({a[i], b[i]}); } sort(one.begin(), one.end()); sort(two.begin(), two.end()); string ans(n, 'R'); int f = 1; for(auto [l, r] : one){ while(f <= l){ ans[f] = ans[f-1] == 'R'? 'B' : 'R'; ++f; } while(f <= r){ ans[f] = ans[f-1]; ++f; } } // constructed a coloring, lets check if it is valid vector<int> vld(two.size(), 1); int diff = 1, idx = 0; while(diff < n){ while(diff < n && ans[diff] == ans[diff - 1]) ++diff; if(diff == n) break; while(idx < two.size() && two[idx].first < diff){ if(two[idx].second >= diff) vld[idx] = 1; ++idx; } } for(int i : vld) if(!i) return 0; craft(ans); return 1; }

Compilation message (stderr)

gift.cpp: In function 'int construct(int, int, int*, int*, int*)':
gift.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   while(idx < two.size() && two[idx].first < diff){
      |         ~~~~^~~~~~~~~~~~
/tmp/ccg4rGp8.o: In function `construct(int, int, int*, int*, int*)':
gift.cpp:(.text+0x639): undefined reference to `craft(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccjbr2qg.o: In function `main':
grader.cpp:(.text.startup+0x290): undefined reference to `construct(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status