# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
243986 | ctziapo | 로봇 (IOI13_robots) | C++14 | 3084 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#include "robots.h"
#include<algorithm>
#include<iostream>
#include<vector>
struct diplo{
int x;
int y;
int i;
};
bool ff(diplo x,diplo y){
return x.y>y.y || x.y==y.y && x.x>y.x;
}
bool ff2(diplo x,diplo y){
return x.x>y.x || x.x==y.x && x.y>y.y;
}
using namespace std;
int putaway(int a, int b, int n, int x[], int y[], int w[], int s[]) {
int f[n]={};
sort(x,x+a);
sort(y,y+b);
for(int i=0;i<n;i++){
if(w[i]>=x[a-1])
f[i]++;
}
for(int i=0;i<n;i++){
if(s[i]>=y[b-1])
f[i]++;
}
for(int i=0;i<n;i++){
if(f[i]==2){
f[0]=-1;
}
//cout<<f[i]<<" ";
}
if(f[0]==-1)
return -1;
vector < diplo > row;
vector < vector < diplo > > vx(a+2,row);
for(int i=0;i<a;i++){
for(int j=0;j<n;j++){
if(x[i]>w[j]){
diplo t;
t.x=w[j];
t.y=s[j];
t.i=j;
vx[i].push_back(t);
}
}
}
vector < diplo > row2;
vector < vector < diplo > > vy(b+2,row2);
for(int i=0;i<b;i++){
for(int j=0;j<n;j++){
if(y[i]>s[j]){
diplo t;
t.x=w[j];
t.y=s[j];
t.i=j;
vy[i].push_back(t);
}
}
}
/*
cout<<endl;
for(int i=0;i<a;i++){
cout<<x[i]<<" : ";
sort(vx[i].begin() , vx[i].end(),ff);
for(int j=0;j<vx[i].size();j++){
cout<<vx[i][j].x<<" "<<vx[i][j].y<<" ."<<vx[i][j].i<<" / ";
}
cout<<endl;
}
cout<<endl;
for(int i=0;i<b;i++){
cout<<y[i]<<" : ";
sort(vy[i].begin() , vy[i].end(),ff2);
for(int j=0;j<vy[i].size();j++){
cout<<vy[i][j].x<<" "<<vy[i][j].y<<" ."<<vy[i][j].i<<" / ";
}
cout<<endl;
}
*/
int ans=n+2;
int l=1;
int r=n;
while(l<=r){
int mid=(l+r)/2;
int c[n]={};
int k=mid;
int c2=0;
for(int i=0;i<a;i++){
sort(vx[i].begin() , vx[i].end(),ff);
int cou=0;
for(int j=0;j<vx[i].size();j++){
if(c[vx[i][j].i]==0){
c[vx[i][j].i]=1;
cou++;
c2++;
}
if(cou==k)
break;
}
// for(int j=0;j<n;j++){
// cout<<c[j]<<" ";
// }
//cout<<endl;
}
for(int i=0;i<b;i++){
sort(vy[i].begin() , vy[i].end(),ff2);
int cou=0;
for(int j=0;j<vy[i].size();j++){
if(c[vy[i][j].i]==0){
c[vy[i][j].i]=1;
cou++;
c2++;
}
if(cou==k)
break;
}
// for(int j=0;j<n;j++){
// cout<<c[j]<<" ";
// }
// cout<<endl;
// cout<<endl;
}
// cout<<c2<<endl;
// cout<<"k "<<k<<endl;
if(c2==n){
ans=min(ans,k);
r=k-1;
}
else
l=k+1;
//cout<<ans<<endl;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |