Skip to content

Commit

Permalink
Add boat shipping logics
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfo123 committed Mar 16, 2024
1 parent 5cc4180 commit 01abc84
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 27 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ Several bugs still exists
# 当前问题
对于机器人碰撞问题仍没有很强有力的解决方法
# to-do-list
Structure
Class: Item, Robot, Berth, Boat
### Structure

3.11 209234
Class: Item, Robot, Berth, Boat

### -s 22222
3.7 212640---222717
3.11 209234?
### Local Test
#### -s 22222
3.7 212640---222717

3.8 188615---208772
3.8 188615---208772--224167(Max 251750)

3.9 186859---187784
3.9 186859---187784

3.10 126147---143968(165616)
3.10 126147---143968 (Max 165616)

3.11 186661---216383(270949)
3.11 186661---216383 (Max 270949)

3.12 250730/249905---265234(32w)
3.12 250730/249905---265234 (Max 32w)

3.13 208264---230350(278884)
3.13 208264---230350 (Max 278884)

53 changes: 37 additions & 16 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void Init()
scanf("%d%d%d%d", &berth[idd].x, &berth[idd].y, &berth[idd].transport_time, &berth[idd].loading_speed);
berth[idd].now_items = 0;
berth[idd].boat_is_coming = 0;
cerr<<berth[idd].transport_time<<endl;
// pair<int,int> m = check_region(berth[idd].x,berth[idd].y);
// berth[idd].x = m.first;
// berth[idd].y = m.second;
Expand All @@ -156,6 +157,8 @@ void Init()
bfs(Point(berth[idd].x, berth[idd].y),dist_berth[idd]);
}
scanf("%d", &boat_capacity);
cerr<<boat_capacity<<endl;

char okk[100];
scanf("%s", okk);
printf("OK\n");
Expand Down Expand Up @@ -412,21 +415,38 @@ void handle_boat(int boat_id,int nowzhen)
int items_have_get = (nowzhen-boat[boat_id].startzhen)*berth[boat[boat_id].pos].loading_speed;
if(items_have_get >= berth[boat[boat_id].pos].now_items) //100
{
if(boat[boat_id].items+items_have_get < 30)
if(boat[boat_id].items+berth[boat[boat_id].pos].now_items < 60 && nowzhen < 13500)
{
while(!q.empty()){
int i = q.top().second;
q.pop();
if(berth[i].boat_is_coming == 0){
printf("ship %d %d\n", boat_id, i);
berth[i].boat_is_coming = 1;
boat[boat_id].items += items_have_get;
if(berth[i].now_items == 0)
{
printf("go %d\n",boat_id);
boat[boat_id].items = 0;
}
else
{
printf("ship %d %d\n", boat_id, i);
cerr<<boat_id<<" ship from berth "<<boat[boat_id].pos<<" to "<<i<<endl;
cerr<<"items_get(optimal) "<<items_have_get<<",total_get "<<boat[boat_id].items+berth[boat[boat_id].pos].now_items<<endl;
cerr<<endl;
berth[i].boat_is_coming = 1;
boat[boat_id].items += berth[boat[boat_id].pos].now_items;
}
break;
}
}
}
else{
else if(nowzhen > 13500 &&nowzhen + berth[boat[boat_id].pos].transport_time < 14990&&boat[boat_id].items+berth[boat[boat_id].pos].now_items <= boat_capacity)
{
return;
}
else {
printf("go %d\n",boat_id);
cerr<<boat_id<<" go from berth "<<boat[boat_id].pos<<endl;
cerr<<"items_have_get "<<boat[boat_id].items+berth[boat[boat_id].pos].now_items<<endl;
boat[boat_id].items = 0;
}
berth[boat[boat_id].pos].now_items = 0;
Expand All @@ -437,6 +457,7 @@ void handle_boat(int boat_id,int nowzhen)
}
else if(boat[boat_id].items+items_have_get >= boat_capacity) //100
{
cerr<<"aaaaa!"<<endl;
printf("go %d\n",boat_id);
berth[boat[boat_id].pos].now_items -= items_have_get;
// berth[boat[boat_id].pos].now_items_value = 0;
Expand All @@ -445,7 +466,7 @@ void handle_boat(int boat_id,int nowzhen)
boat[boat_id].items = 0;
boat[boat_id].startzhen = 0;
}
else if(nowzhen + berth[boat[boat_id].pos].transport_time > 14998)
else if(nowzhen + berth[boat[boat_id].pos].transport_time > 14996)
{
printf("go %d\n",boat_id);
berth[boat[boat_id].pos].now_items = 0;
Expand Down Expand Up @@ -482,16 +503,16 @@ int main()
handle_robot(i,id);
for(int i = 0;i < 5;i++)
handle_boat(i,id);
// if(zhen == 15000)
// {
// int cnt = 0;
// for(int i = 0;i < 10;i++)
// {
// cerr<<berth[i].now_items_value<<endl;
// cnt+=berth[i].now_items_value;
// }
// cerr<<cnt<<endl;
// }
if(zhen == 15000)
{
int cnt = 0;
for(int i = 0;i < 10;i++)
{
cerr<<berth[i].now_items_value<<endl;
cnt+=berth[i].now_items_value;
}
cerr<<cnt<<endl;
}
puts("OK");
fflush(stdout);
}
Expand Down

0 comments on commit 01abc84

Please sign in to comment.