제출 #306838

#제출 시각아이디문제언어결과실행 시간메모리
306838joylintpHandcrafted Gift (IOI20_gift)C++14
25 / 100
262 ms16992 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 >= 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 = lower_bound(v2.begin(), v2.end(), a[i]) - v2.begin(); if (pos < v2.size() && pos % 2 == 0 && b[i] <= v2[pos + 1]) return 0; } craft(s); return 1; }

컴파일 시 표준 에러 (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++)
      |                     ~~^~~~~~~~~~
gift.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if (pos < v2.size() && pos % 2 == 0 && b[i] <= v2[pos + 1])
      |             ~~~~^~~~~~~~~~~
#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...