# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245213 | ctziapo | Robots (IOI13_robots) | C++14 | 209 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
#include "robots.h"
#include<algorithm>
#include<iostream>
#include<vector>
struct diplo{
long long int x;
long long int y;
long long 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 f[20000];
vector < diplo > row;
vector < vector < diplo > > vx(10000,row);
vector < diplo > row2;
vector < vector < diplo > > vy(10000,row2);
int putaway(int a, int b, int n, int x[], int y[], int w[], int s[]) {
if(a!=0)
sort(x,x+a);
if(b!=0)
sort(y,y+b);
if(a!=0)
for(long long i=0;i<n;i++){
if(w[i]>=x[a-1])
f[i]++;
}
if(b!=0)
for(long long i=0;i<n;i++){
if(s[i]>=y[b-1])
f[i]++;
}
for(long long i=0;i<n;i++){
if(f[i]==2){
f[0]=-1;
}
//cout<<f[i]<<" ";
}
if(f[0]==-1)
return -1;
for(long long i=0;i<a;i++){
for(long long 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);
}
}
}
for(long long i=0;i<b;i++){
for(long long 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(long long i=0;i<a;i++){
cout<<x[i]<<" : ";
sort(vx[i].begin() , vx[i].end(),ff);
for(long long 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(long long i=0;i<b;i++){
cout<<y[i]<<" : ";
sort(vy[i].begin() , vy[i].end(),ff2);
for(long long j=0;j<vy[i].size();j++){
cout<<vy[i][j].x<<" "<<vy[i][j].y<<" ."<<vy[i][j].i<<" / ";
}
cout<<endl;
}
*/
long long ans=1000000;
long long l=1;
long long r=n;
while(l<=r){
long long mid=(l+r)/2;
long long c[20000]={};
long long k=mid;
long long c2=0;
for(long long i=0;i<a;i++){
sort(vx[i].begin() , vx[i].end(),ff);
long long cou=0;
for(long long 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(long long j=0;j<n;j++){
// cout<<c[j]<<" ";
// }
//cout<<endl;
}
for(long long i=0;i<b;i++){
// sort(vy[i].begin() , vy[i].end(),ff2);
long long cou=0;
for(long long 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(long long 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;
}
Compilation message (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... |