제출 #964953

#제출 시각아이디문제언어결과실행 시간메모리
964953Acanikolic로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#define int long long #define pb push_back #define F first #define S second using namespace std; const int N = 1000000 + 10; const int mod = 1e9 + 7; const int inf = 1e9; bool check(int A,int B,int T,vector<int>X,vector<int>Y,vector<pair<int,int>>W,vector<pair<int,int>>S,int mid) { vector<bool>vis(T,false); priority_queue<int>pq; int ptr = -1; for(int i = 0; i < T; i++) { if(pq.empty() && ptr + 1 < A && X[ptr + 1] > W[i].F) { for(int j = 0; j < mid; j++) { pq.push(X[ptr + 1]); } ptr += 1; } if(mid == 3 && i == 1) { //cout << "debug:" << X[ptr + 1] << " " << W[i].F << " " << W[i].S << endl; } if(pq.empty()) continue; vis[W[i].S] = true; pq.pop(); } if(mid == 3) { //for(int i = 0; i < T; i++) if(vis[i]) cout << "dbg:::" << i << endl; //cout << endl; } while(pq.size()) pq.pop(); ptr = -1; for(int i = 0; i < T; i++) { if(vis[S[i].S]) continue; if(pq.empty() && ptr + 1 < B && Y[ptr + 1] > S[i].F) { for(int j = 0; j < mid; j++) { pq.push(Y[ptr + 1]); } ptr += 1; } if(pq.empty()) continue; vis[S[i].S] = true; pq.pop(); } bool ok = true; for(int i = 0; i < T; i++) if(!vis[i]) ok = false; if(mid == 3) { // for(int i = 0; i < T; i++) if(vis[i]) cout << "dbg:::" << i << endl; } if(ok) return true; while(pq.size()) pq.pop(); for(int i = 0; i < T; i++) vis[i] = false; ptr = -1; for(int i = 0; i < T; i++) { if(pq.empty() && ptr + 1 < B && Y[ptr + 1] > S[i].F) { for(int j = 0; j < mid; j++) { pq.push(Y[ptr + 1]); } ptr += 1; } if(pq.empty()) continue; vis[S[i].S] = true; pq.pop(); } while(pq.size()) pq.pop(); ptr = -1; for(int i = 0; i < T; i++) { if(vis[W[i].S]) continue; if(pq.empty() && ptr + 1 < A && X[ptr + 1] > W[i].F) { for(int j = 0; j < mid; j++) { pq.push(X[ptr + 1]); } ptr += 1; } if(pq.empty()) continue; vis[W[i].S] = true; pq.pop(); } ok = true; for(int i = 0; i < T; i++) if(!vis[i]) ok = false; return ok; } int putaway(int A,int B,int T,vector<int>X,vector<int>Y,vector<int>W,vector<int>S) { vector<pair<int,int>>w(T); vector<pair<int,int>>s(T); for(int i = 0; i < T; i++) { w[i] = {W[i],i}; s[i] = {S[i],i}; } sort(X.begin(),X.end()); sort(Y.begin(),Y.end()); sort(w.begin(),w.end()); sort(s.begin(),s.end()); reverse(X.begin(),X.end()); reverse(Y.begin(),Y.end()); reverse(w.begin(),w.end()); reverse(s.begin(),s.end()); int l = 1, r = max(A,B),ans = -1; while(l <= r) { int mid = (l + r) / 2; if(check(A,B,T,X,Y,w,s,mid)) { ans = mid; r = mid - 1; }else { l = mid + 1; } } return ans; }

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

/usr/bin/ld: /tmp/ccvms2DO.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status