제출 #769420

#제출 시각아이디문제언어결과실행 시간메모리
769420boris_mihovRobots (IOI13_robots)C++17
0 / 100
3071 ms33640 KiB
#include "robots.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <bitset> #include <set> typedef long long llong; const int MAXN = 1000000 + 10; const int MAXAB = 50000 + 10; int n; int a, b; int w[MAXN]; int s[MAXN]; int permX[MAXN]; int permY[MAXN]; std::multiset <int> vals; int check(int times, int X[], int Y[]) { vals.clear(); int ptr = 0; int cntDestroyed = 0; for (int curr = 1 ; curr <= a ; ++curr) { while (ptr + 1 <= n && w[permX[ptr + 1]] <= X[curr - 1]) { vals.insert(s[permX[ptr + 1]]); ptr++; } for (int t = 1 ; t <= times && vals.size() ; ++t) { vals.erase(std::prev(vals.end())); } } while (ptr + 1 <= n) { vals.insert(s[permX[ptr + 1]]); ptr++; } for (int curr = 1 ; curr <= b && vals.size() ; ++curr) { for (int t = 1 ; t <= times && vals.size() ; ++t) { auto it = vals.upper_bound(Y[curr - 1]); if (it == vals.begin()) { break; } else { it = std::prev(it); vals.erase(it); } } } return vals.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; n = T; for (int i = 1 ; i <= n ; ++i) { w[i] = W[i - 1] + 1; s[i] = S[i - 1] + 1; } std::iota(permX + 1, permX + 1 + n, 1); std::sort(permX + 1, permX + 1 + n, [&](const int &a, const int &b) { return w[a] < w[b]; }); std::iota(permY + 1, permY + 1 + n, 1); std::sort(permY + 1, permY + 1 + n, [&](const int &a, const int &b) { return s[a] < s[b]; }); std::sort(X, X + a); std::sort(Y, Y + b); // std::cout << "byW\n"; // for (int i = 1 ; i <= n ; ++i) // { // std::cout << w[sortedX.perm[i]] << ' ' << s[sortedX.perm[i]] << '\n'; // } // std::cout << "byS\n"; // for (int i = 1 ; i <= n ; ++i) // { // std::cout << w[sortedY.perm[i]] << ' ' << s[sortedY.perm[i]] << '\n'; // } int pw = -1; while (!check(1 << pw + 1, X, Y)) pw++; int l = (pw == -1 ? 0 : (1 << pw)), r = (1 << pw + 1), mid; while (l < r - 1) { mid = (l + r) / 2; if (!check(mid, X, Y)) l = mid; else r = mid; } check(2, X, Y); if (r == n + 1) return -1; return r; }

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

robots.cpp: In function 'int check(int, int*, int*)':
robots.cpp:26:9: warning: unused variable 'cntDestroyed' [-Wunused-variable]
   26 |     int cntDestroyed = 0;
      |         ^~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:106:27: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
  106 |     while (!check(1 << pw + 1, X, Y)) pw++;
      |                        ~~~^~~
robots.cpp:108:54: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
  108 |     int l = (pw == -1 ? 0 : (1 << pw)), r = (1 << pw + 1), mid;
      |                                                   ~~~^~~
#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...