NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

/**
* Score points by scanning valuable fish faster than your opponent.
**/

typedef struct fishs
{
int id;
int x;
int y;
int is_active;
struct fishs *next;
} fish;

fish *ft_lstnew(int id, int x, int y)
{
fish *new_node;

new_node = (fish *)malloc(sizeof(fish));
if (!new_node)
return (NULL);
new_node->id = id;
new_node->x = x;
new_node->y = y;
new_node->is_active = 0;
new_node->next = NULL;
return (new_node);
}

fish *ft_lstlast(fish *lst)
{
if (!lst)
return (NULL);
while (lst->next != NULL)
lst = lst->next;
return (lst);
}

void ft_lstadd_back(fish **lst, fish *new)
{
if (!lst || !new)
return ;
if (*lst)
ft_lstlast(*lst)->next = new;
else
*lst = new;
}

int main()
{
int my_drone_x = 0;
int my_drone_y = 0;
int target_x = 2000;
int target_y = 2000;
int my_battery = 0;
int first_x = -1;
int loop = 0;
int revers = 0;

int creature_count;
scanf("%d", &creature_count);
for (int i = 0; i < creature_count; i++) {
int creature_id;
int color;
int type;
scanf("%d%d%d", &creature_id, &color, &type);
}

// game loop
while (1) {
int my_score;
scanf("%d", &my_score);
int foe_score;
scanf("%d", &foe_score);
int my_scan_count;
scanf("%d", &my_scan_count);
for (int i = 0; i < my_scan_count; i++) {
int creature_id;
scanf("%d", &creature_id);
}
int foe_scan_count;
scanf("%d", &foe_scan_count);
for (int i = 0; i < foe_scan_count; i++) {
int creature_id;
scanf("%d", &creature_id);
}
int my_drone_count;
scanf("%d", &my_drone_count);
for (int i = 0; i < my_drone_count; i++) {
int drone_id;
int drone_x;
int drone_y;
int emergency;
int battery;
scanf("%d%d%d%d%d", &drone_id, &drone_x, &drone_y, &emergency, &battery);
my_drone_x = drone_x;
my_drone_y = drone_y;
my_battery = battery;
if (first_x == -1)
{
first_x = drone_x;
if (drone_x > 5000)
target_x = 8500;
}
}
int foe_drone_count;
scanf("%d", &foe_drone_count);
for (int i = 0; i < foe_drone_count; i++) {
int drone_id;
int drone_x;
int drone_y;
int emergency;
int battery;
scanf("%d%d%d%d%d", &drone_id, &drone_x, &drone_y, &emergency, &battery);
}
int drone_scan_count;
scanf("%d", &drone_scan_count);
for (int i = 0; i < drone_scan_count; i++) {
int drone_id;
int creature_id;
scanf("%d%d", &drone_id, &creature_id);
}
int visible_creature_count;
scanf("%d", &visible_creature_count);
for (int i = 0; i < visible_creature_count; i++) {
int creature_id;
int creature_x;
int creature_y;
int creature_vx;
int creature_vy;
scanf("%d%d%d%d%d", &creature_id, &creature_x, &creature_y, &creature_vx, &creature_vy);
}
int radar_blip_count;
scanf("%d", &radar_blip_count);
for (int i = 0; i < radar_blip_count; i++) {
int drone_id;
int creature_id;
char radar[3];
scanf("%d%d%s", &drone_id, &creature_id, radar);
}
for (int i = 0; i < my_drone_count; i++) {
if (loop == 0 && revers == 0)
{
if (first_x < 5000)
{
if (target_y < 8000 && target_y != 0)
target_y = 8000;
if (my_drone_y >= 8000)
target_x = 8000;
if (my_drone_x == 8000)
{
target_y = 0;
loop = 1;
}
}
else
{
if (target_y < 8000 && target_y != 0)
target_y = 8000;
if (my_drone_y >= 8000)
target_x = 2000;
if (my_drone_x == 2000)
{
target_y = 0;
loop = 1;
}
}
}
if (loop == 0 && revers == 1)
{
if (first_x < 5000)
{
if (target_y < 8000 && target_y != 0)
target_y = 8000;
if (my_drone_y >= 8000)
target_x = 2000;
if (my_drone_x == 2000)
{
target_y = 0;
loop = 1;
}

}
else
{
if (target_y < 8000 && target_y != 0)
target_y = 8000;
if (my_drone_y >= 8000)
target_x = 8000;
if (my_drone_x == 8000)
{
target_y = 0;
loop = 1;
}
}
}
if (loop == 1 && my_drone_x == 5000)
{
target_y = 0;
}
if (my_drone_y == 0)
{
loop = 0;
target_y = 2000;
if (first_x < 5000)
first_x = 7000;
else if (first_x > 5000)
first_x = 2000;
revers = 1;
}
// Write an action using printf(). DON'T FORGET THE TRAILING n
// To debug: fprintf(stderr, "Debug messages...n");
if (my_battery >= 5 && my_drone_y > 2000)
printf("MOVE %d %d 1n", target_x, target_y); // MOVE <x> <y> <light (1|0)> | WAIT <light (1|0)>
else
{
printf("MOVE %d %d 0n", target_x, target_y);
}
}
}

return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.