Benbircoderim1_'s blog

By Benbircoderim1_, history, 2 months ago, In English

My code for "Magnets" problem works on gcc version 6.1 but codeforces uses gcc 5.1. Is it version related runtime error.


Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead.

Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other 
and the opposite poles will attract each other.

Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row.
 Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) 
 or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.


#include <stdio.h>
#define SIZE 100000L

void TakeMagSize(long *a)

void StoreMagnetType(long *a, long b)
    for (long i = 0; i < b; i++)

void calc(long *a, long b)
    int groupcounter=0;
    int temp=0;

    for (long i = 0; i < b; i++)
        if(temp!=a[i])    groupcounter++;

int main(void)
    long mag;
    long magnets[SIZE];
    long counter;
    calc(magnets, mag);

    return 1;
  • Vote: I like it
  • 0
  • Vote: I do not like it

2 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Try to submit it with changing return 1 to "return 0;". It is not about gcc version