제출 #896693

#제출 시각아이디문제언어결과실행 시간메모리
896693juliany2Event Hopping 2 (JOI21_event2)C++17
32 / 100
3049 ms6424 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; #define all(x) (x).begin(), (x).end() int main() { cin.tie(0)->sync_with_stdio(false); int n, k; cin >> n >> k; vector<array<int, 2>> a(n); for (auto &[l, r] : a) cin >> l >> r; vector<array<int, 2>> b = a; sort(all(b), [&](array<int, 2> &x, array<int, 2> &y) { return x[1] < y[1]; }); vector<int> ans; for (int i = 0; i < n; i++) { if (ans.size() == k || !count(all(b), a[i])) continue; vector<array<int, 2>> c; for (auto &[l, r] : b) if (r <= a[i][0] || l >= a[i][1]) c.push_back({l, r}); int cnt = 0, p = -1; for (auto &[l, r] : c) { if (l >= p) cnt++, p = r; } if (cnt + ans.size() + 1 >= k) { ans.push_back(i + 1); b = c; } } if (ans.size() < k) cout << -1 << '\n'; else { for (int i : ans) cout << i << '\n'; } return 0; }

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

event2.cpp: In function 'int main()':
event2.cpp:22:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         if (ans.size() == k || !count(all(b), a[i]))
      |             ~~~~~~~~~~~^~~~
event2.cpp:36:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |         if (cnt + ans.size() + 1 >= k) {
      |             ~~~~~~~~~~~~~~~~~~~~~^~~~
event2.cpp:42:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     if (ans.size() < k)
      |         ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...