제출 #241646

#제출 시각아이디문제언어결과실행 시간메모리
241646abacaba로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <cstring> #include <chrono> #include <vector> #include <map> #include <random> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define emb emplace_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), "r", stdin); } inline void setout(string s) { freopen(s.c_str(), "w", stdout); } template <typename T> void Min(T &a, T b) { a = min(a, b); } template <typename T> void Max(T &a, T b) { a = max(a, b); } const int inf = 1e9; const int mod = 998244353; const int N = 1e6 + 15; int a[N], b[N]; pii s[N]; int n, m, t; bool used[N]; int cnt[2][N]; set <pii> is; inline bool check(int mid) { is.clear(); for(int i = 1; i <= n; ++i) { cnt[0][i] = mid; is.insert({a[i], i}); } for(int i = 1; i <= m; ++i) cnt[1][i] = mid; for(int i = 1; i <= t; ++i) used[i] = false; for(int i = 1; i <= t; ++i) { set <pii>::iterator it = is.upper_bound({s[i].se, -1}); if(it == is.end()) continue; used[i] = true; --cnt[0][it->se]; if(cnt[0][it->se] == 0) is.erase(it); } for(int i = 1, j = 1; i <= t; ++i) { if(!used[i]) { if(cnt[1][j] == 0) ++j; if(j > m || b[j] <= s[i].f) return false; cnt[1][j]--; used[i] = true; } } return true; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n = A, m = B, t = T; for(int i = 0; i < n; ++i) a[i + 1] = X[i]; for(int i = 0; i < m; ++i) b[i + 1] = Y[i]; sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + m); for(int i = 0; i < t; ++i) { s[i + 1] = {W[i], S[i]}; if(upper_bound(a + 1, a + 1 + n, W[i]) - a == n + 1 && upper_bound(b + 1, b + 1 + m, S[i]) - b == m + 1) return -1; } sort(s + 1, s + 1 + t, [&](pii a, pii b) { return a > b; }); int l = 1, r = t, res = -1; while(l <= r) { int mid = l + r >> 1; if(check(mid)) r = mid - 1, res = mid; else l = mid + 1; } return res; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:124:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = l + r >> 1;
                   ~~^~~
/tmp/ccSLk7HO.o: In function `main':
grader.c:(.text.startup+0x17e): undefined reference to `putaway'
collect2: error: ld returned 1 exit status