Please subscribe to the official Codeforces channel in Telegram via the link: ×

A.K.Goharshady's blog

By A.K.Goharshady, 8 years ago, In English,
Problem A:
This was indeed the easiest problem. You just needed to XOR the given sequences.
The only common mistake was removing initial 0s which led to "Wrong Answer"
Common mistake in hacks which led to "Invalid Input" was forgetting that all lines in input ends with EOLN.

  • Vote: I like it  
  • +1
  • Vote: I do not like it  

2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My code works CORRECTLY in my laptop but it says WRONG ANSWER here. I am unable to figure out where am I making the mistake. Kindly help : /* * @author : SRvSaha * Filename : ultra_fast_mathematician.c * Timestamp : 09:10 PM 05-JUL-2016 * Description : * */ #include <stdio.h> char xor(char p, char q) { if(p == q){ return '0'; } else return '1'; } int main() { char str1[101]; char str2[101]; char output[101]; scanf("%s",str1); scanf("%s",str2); for(int i = 0; str1[i] != '\0'; i++){ output[i] = xor(str1[i],str2[i]); } printf("%s\n",output); return 0; } <\CODE>

  • »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You do not add \0 at the end of output. Your compiler seems to initialize array with zeros but this is not true for testing system.