Submission #306845

#TimeUsernameProblemLanguageResultExecution timeMemory
306845joylintpHandcrafted Gift (IOI20_gift)C++14
70 / 100
267 ms17108 KiB
#include"gift.h" #include<bits/stdc++.h> using namespace std; int construct (int n, int r, vector<int> a, vector<int> b, vector<int> x) { vector<pair<int, int>> v; for (int i = 0; i < r; i++) if (x[i] == 1) v.push_back({a[i], b[i]}); sort(v.begin(), v.end()); vector<pair<int, int>> same; for (int i = 0; i < v.size(); i++) if (same.empty()) same.push_back(v[i]); else if (same.back().second + 1 >= v[i].first) same.back().second = max(same.back().second, v[i].second); else same.push_back(v[i]); string s(n, '_'); for (auto p : same) for (int i = p.first; i <= p.second; i++) s[i] = 'R'; for (int i = 0; i < n; ) if (s[i] == '_') { int j = i; while (j < n && s[j] == '_') s[j] = "BR"[(j - i) % 2], j++; i = j; } else i++; vector<int> v2; for (auto p : same) v2.push_back(p.first), v2.push_back(p.second); for (int i = 0; i < r; i++) { if (x[i] == 1) continue; if (a[i] == b[i]) return 0; int pos = upper_bound(v2.begin(), v2.end(), a[i]) - v2.begin() - 1; if (pos != -1 && pos % 2 == 0 && b[i] <= v2[pos + 1]) return 0; } craft(s); return 1; }

Compilation message (stderr)

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...