제출 #1083156

#제출 시각아이디문제언어결과실행 시간메모리
1083156vladilius팀들 (IOI15_teams)C++17
0 / 100
4041 ms20676 KiB
#include <bits/stdc++.h> #include "teams.h" using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert int n; vector<int> a, b; vector<pii> st; void init(int N, int A[], int B[]){ n = N; a.resize(n + 1); for (int i = 1; i <= n; i++) a[i] = A[i - 1]; b.resize(n + 1); for (int i = 1; i <= n; i++) b[i] = B[i - 1]; for (int i = 1; i <= n; i++) st.pb({a[i], b[i]}); sort(st.begin(), st.end()); } int pr(int x, int y){ int out = 0; for (auto [u, v]: st){ out += (u <= x && v <= y); } return out; } int sum(int x1, int y1, int x2, int y2){ return pr(x2, y2) + pr(x1, y1) - pr(x1 - 1, y2) - pr(x2, y1 - 1); } int can(int m, int K[]){ vector<int> k(m + 1); for (int i = 1; i <= m; i++) k[i] = K[i - 1]; sort(k.begin() + 1, k.end()); vector<pii> st; vector<int> pr = {0}; auto get = [&](int x, int y){ if (st.empty()) return sum(0, x, x, y); int l = 0, r = (int) st.size() - 1; while (l + 1 < r){ int m = (l + r) / 2; if (st[m].ss >= y){ l = m; } else { r = m - 1; } } if (st[r].ss >= y) l = r; if (st[l].ss < y) l = -1; int out = sum(0, x, x, y); if (l != -1) out -= sum(0, x, st[l].ff, y); if (l < pr.size()) out -= (pr.back() - pr[l]); return out; }; auto add = [&](int x, int y){ while (!st.empty() && st.back().ss <= y){ st.pop_back(); pr.pop_back(); } if (st.empty()) pr.pb(sum(0, x, x, y)); else pr.pb(pr.back() + sum(0, st.back().ff, x, y)); st.pb({x, y}); }; for (int i = 1; i <= m; i++){ while (!st.empty() && st.back().ss <= k[i]) st.pop_back(); if (get(k[i], n) < k[i]) return 0; int l = k[i], r = n; while (l + 1 < r){ int m = (l + r) / 2; if (get(k[i], m) < k[i]){ l = m + 1; } else { r = m; } } if (get(k[i], l) >= k[i]) r = l; add(k[i], r); } return 1; }

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

teams.cpp: In function 'int can(int, int*)':
teams.cpp:43:17: warning: declaration of 'st' shadows a global declaration [-Wshadow]
   43 |     vector<pii> st;
      |                 ^~
teams.cpp:13:13: note: shadowed declaration is here
   13 | vector<pii> st;
      |             ^~
teams.cpp: In lambda function:
teams.cpp:50:17: warning: declaration of 'int m' shadows a parameter [-Wshadow]
   50 |             int m = (l + r) / 2;
      |                 ^
teams.cpp:38:13: note: shadowed declaration is here
   38 | int can(int m, int K[]){
      |         ~~~~^
teams.cpp:64:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if (l < pr.size()) out -= (pr.back() - pr[l]);
      |             ~~^~~~~~~~~~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:87:17: warning: declaration of 'int m' shadows a parameter [-Wshadow]
   87 |             int m = (l + r) / 2;
      |                 ^
teams.cpp:38:13: note: shadowed declaration is here
   38 | int can(int m, int 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...