제출 #355373

#제출 시각아이디문제언어결과실행 시간메모리
355373dolphingarlicHandcrafted Gift (IOI20_gift)C++14
10 / 100
237 ms24916 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>> sing, doub, itv; for (int i = 0; i < r; i++) { if (x[i] == 1) sing.push_back({a[i], b[i]}); else doub.push_back({a[i], b[i]}); } sort(sing.begin(), sing.end()); pair<int, int> curr = {-1, -1}; for (pair<int, int> i : sing) { if (i.first > curr.second) { itv.push_back(curr); curr = i; } else curr.second = max(curr.second, i.second); } itv.push_back(curr); sort(doub.begin(), doub.end()); int s_ptr = 1; for (pair<int, int> i : doub) { while (s_ptr < itv.size() - 1 && itv[s_ptr].second < i.first) s_ptr++; if (i.first == i.second || (i.first >= itv[s_ptr].first && i.second <= itv[s_ptr].second)) return 0; } string ret(n, '.'); char c = 'R'; for (int i = 1; i < itv.size(); i++) { for (int j = itv[i - 1].second + 1; j < itv[i].first; j++) { ret[j] = c; c = 'R' + 'B' - c; } for (int j = itv[i].first; j <= itv[i].second; j++) ret[j] = c; c = 'R' + 'B' - c; } for (int j = itv.back().second + 1; j < n; j++) { ret[j] = c; c = 'R' + 'B' - c; } craft(ret); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         while (s_ptr < itv.size() - 1 && itv[s_ptr].second < i.first)
      |                ~~~~~~^~~~~~~~~~~~~~~~
gift.cpp:32: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]
   32 |     for (int i = 1; i < itv.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...