이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
#define pb push_back
#define fi first
#define se second
#define whole(v) v.begin(), v.end()
#define rwhole(v) v.rbegin(), v.rend()
#define inf INT_MAX/2
#define fro front
bool cmp(vi a, vi b) {
return a.size() < b.size();
}
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]){
int mem[t];
memset(mem, - 1, sizeof mem);
if(a == 0){
swap(w, s);
swap(x, y);
swap(a, b);
}
if(b == 0){
sort(w, w + a);
sort(x, x + t);
int cnt = 0;
int ans = 0;
while(cnt < t){
if(ans > t) return -1;
ans++;
int i = 0;
int j = 0;
while(i < t && j < a){
if(x[j] > w[i]){
if(mem[i] == 10){
i++;
continue;
}
mem[i] = 10;
++i;
++j;
cnt++;
}else{
j++;
}
}
}
return ans;
}
ii ww[t];
for(int i = 0; i < t; ++i){
ww[i] = ii(w[i], i);
}
ii ss[t];
for(int i = 0; i < t; ++i){
ss[i] = ii(s[i], i);
}
sort(ww, ww+t); sort(ss, ss+t);
reverse(ww, ww+t); reverse(ss, ss+t);
vector<vi> n(a + b);
for(int i = 0; i < a; ++i){
int k = x[i];
for(int j = 0; j < t; ++j){
if(ww[j].first < k){
n[i].pb(ww[j].second);
mem[ww[j].second] = 1;
}
}
}
for(int i = 0; i < b; ++i){
int k = y[i];
for(int j = 0; j < t; ++j){
if(ss[j].first < k){
n[a + i].pb(ss[j].second);
mem[ss[j].second] = 1;
}
}
}
sort(whole(n), cmp);
for(auto e:mem){
if(e == -1){
return -1;
}
}
int ans = 0;
int cnt = 0;
int pos[n.size()];
memset(pos, 0, sizeof pos);
while(cnt < t){
for(int i = 0; i < n.size(); ++i){
if(pos[i] >= n[i].size()){
continue;
}
if(mem[n[i][pos[i]]] == 10){
pos[i]++;
if(pos[i] >= n[i].size()){
pos[i] = 10000000;
++i;
}
i--;
continue;
}else{
mem[n[i][pos[i]]] = 10;
cnt++;
pos[i]++;
if(pos[i] >= n[i].size()){
pos[i] = 10000000;
}
}
}
ans++;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:100:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
100 | for(int i = 0; i < n.size(); ++i){
| ~~^~~~~~~~~~
robots.cpp:101:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
101 | if(pos[i] >= n[i].size()){
| ~~~~~~~^~~~~~~~~~~~~~
robots.cpp:106:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
106 | if(pos[i] >= n[i].size()){
| ~~~~~~~^~~~~~~~~~~~~~
robots.cpp:116:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
116 | if(pos[i] >= n[i].size()){
| ~~~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |